alphaCaml-demos-poplmark.opp.exp 3.14 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
%{

open Strings
open Fsub.Raw

%}
%start toplevel
%token USCORE
%token <string> UCID
%token TTOP
%token SEMI
%token RSQUARE
%token RPAREN
%token RCURLY
%token LSQUARE
%token LPAREN
%token LET
%token LEQ
%token LCURLY
%token <string> LCID
%token LAMBDA
%token IN
%token EQ
%token EOF
%token DOT
%token COMMA
%token COLON
%token ARROW
%token ALL

%type <Fsub.Raw.toplevel> toplevel
%%

toplevel:
35 36 37 38 39 40 41 42
| _1 = EOF
    {      ( TopEOF )}
| _1 = Term _2 = SEMI _3 = toplevel
    {      ( TopEval (_1, _3) )}
| _1 = UCID _2 = TyBinder _3 = SEMI _4 = toplevel
    {      ( TopTypeBind (_1, _2, _4) )}
| _1 = LCID _2 = Binder _3 = SEMI _4 = toplevel
    {      ( TopTermBind (_1, _2, _4) )}
43 44

Binder:
45 46
| _1 = COLON _2 = Type
    {      ( _2 )}
47 48

Type:
49 50 51 52
| _1 = ArrowType
    {      ( _1 )}
| _1 = ALL _2 = UCID _3 = OType _4 = DOT _5 = Type
    {      ( TForall (_2, _3, _5) )}
53 54

AType:
55 56 57 58 59 60 61 62
| _1 = LPAREN _2 = Type _3 = RPAREN
    {      ( _2 )}
| _1 = UCID
    {      ( TVar _1 )}
| _1 = TTOP
    {      ( TTop )}
| _1 = LCURLY _2 = FieldTypes _3 = RCURLY
    {      ( TRecord _2 )}
63 64 65

TyBinder:
| 
66 67 68
    {      ( TTop )}
| _1 = LEQ _2 = Type
    {      ( _2 )}
69 70

ArrowType:
71 72 73 74
| _1 = AType _2 = ARROW _3 = ArrowType
    {     ( TArrow (_1, _3) )}
| _1 = AType
    {     ( _1 )}
75 76

Term:
77 78 79 80 81 82 83 84
| _1 = AppTerm
    {      ( _1 )}
| _1 = LAMBDA _2 = LCID _3 = COLON _4 = Type _5 = DOT _6 = Term
    {      ( EAbs (_2, _4, _6) )}
| _1 = LET _2 = Pattern _3 = EQ _4 = Term _5 = IN _6 = Term
    {      ( ELet (_2, _4, _6) )}
| _1 = LAMBDA _2 = UCID _3 = OType _4 = DOT _5 = Term
    {      ( ETyAbs (_2, _3, _5) )}
85 86

AppTerm:
87 88 89 90 91 92
| _1 = PathTerm
    {      ( _1 )}
| _1 = AppTerm _2 = PathTerm
    {      ( EApp (_1, _2) )}
| _1 = AppTerm _2 = LSQUARE _3 = Type _4 = RSQUARE
    {      ( ETyApp (_1, _3) )}
93 94

PathTerm:
95 96 97 98
| _1 = PathTerm _2 = DOT _3 = LCID
    {      ( EProj (_1, _3) )}
| _1 = ATerm
    {      ( _1 )}
99 100 101

FieldTypes:
| 
102 103 104
    {      ( StringMap.empty )}
| _1 = NEFieldTypes
    {      ( _1 )}
105 106

NEFieldTypes:
107 108 109 110
| _1 = LCID _2 = COLON _3 = Type
    {      ( StringMap.singleton _1 _3 )}
| _1 = LCID _2 = COLON _3 = Type _4 = COMMA _5 = NEFieldTypes
    {      ( StringMap.add _1 _3 _5 )}
111 112

TermSeq:
113 114 115 116
| _1 = Term
    {      ( _1 )}
| _1 = Term _2 = SEMI _3 = TermSeq
    {      ( ELet (PWildcard, _1, _3) )}
117 118

ATerm:
119 120 121 122 123 124
| _1 = LPAREN _2 = TermSeq _3 = RPAREN
    {      ( _2 )}
| _1 = LCID
    {      ( EVar _1 )}
| _1 = LCURLY _2 = Fields _3 = RCURLY
    {      ( ERecord _2 )}
125 126 127

Fields:
| 
128 129 130
    {      ( StringMap.empty )}
| _1 = NEFields
    {      ( _1 )}
131 132

NEFields:
133 134 135 136
| _1 = LCID _2 = EQ _3 = Term
    {      ( StringMap.singleton _1 _3 )}
| _1 = LCID _2 = EQ _3 = Term _4 = COMMA _5 = NEFields
    {      ( StringMap.add _1 _3 _5 )}
137 138 139

OType:
| 
140 141 142
    {      ( TTop)}
| _1 = LEQ _2 = Type
    {      ( _2 )}
143 144

Pattern:
145 146 147 148 149 150
| _1 = USCORE
    {      ( PWildcard )}
| _1 = LCID _2 = COLON _3 = Type
    {      ( PVar (_1, _3) )}
| _1 = LCURLY _2 = PatFields _3 = RCURLY
    {      ( PRecord _2 )}
151 152 153

PatFields:
| 
154 155 156
    {      ( StringMap.empty )}
| _1 = NEPatFields
    {      ( _1 )}
157 158

NEPatFields:
159 160 161 162
| _1 = LCID _2 = EQ _3 = Pattern
    {      ( StringMap.singleton _1 _3 )}
| _1 = LCID _2 = EQ _3 = Pattern _4 = COMMA _5 = NEPatFields
    {      ( StringMap.add _1 _3 _5 )}
163 164 165 166 167

%%