Mercurial > urweb
comparison src/lacweb.grm @ 8:a455a9f85cc3
Parsing basic expressions
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Sat, 26 Jan 2008 17:10:26 -0500 |
parents | 2ce5bf227d01 |
children | d89477f07c1e |
comparison
equal
deleted
inserted
replaced
7:2ce5bf227d01 | 8:a455a9f85cc3 |
---|---|
37 %term | 37 %term |
38 EOF | 38 EOF |
39 | SYMBOL of string | CSYMBOL of string | 39 | SYMBOL of string | CSYMBOL of string |
40 | LPAREN | RPAREN | LBRACK | RBRACK | LBRACE | RBRACE | 40 | LPAREN | RPAREN | LBRACK | RBRACK | LBRACE | RBRACE |
41 | EQ | COMMA | COLON | DCOLON | TCOLON | DOT | HASH | 41 | EQ | COMMA | COLON | DCOLON | TCOLON | DOT | HASH |
42 | CON | LTYPE | 42 | CON | LTYPE | VAL |
43 | TYPE | NAME | 43 | TYPE | NAME |
44 | ARROW | LARROW | DARROW | 44 | ARROW | LARROW | DARROW |
45 | FN | PLUSPLUS | DOLLAR | 45 | FN | PLUSPLUS | DOLLAR |
46 | 46 |
47 %nonterm | 47 %nonterm |
56 | capps of con | 56 | capps of con |
57 | cterm of con | 57 | cterm of con |
58 | ident of con | 58 | ident of con |
59 | rcon of (con * con) list | 59 | rcon of (con * con) list |
60 | rcone of (con * con) list | 60 | rcone of (con * con) list |
61 | |
62 | eexp of exp | |
63 | eapps of exp | |
64 | eterm of exp | |
61 | 65 |
62 %verbose (* print summary of errors *) | 66 %verbose (* print summary of errors *) |
63 %pos int (* positions *) | 67 %pos int (* positions *) |
64 %start file | 68 %start file |
65 %pure | 69 %pure |
86 | 90 |
87 decl : CON SYMBOL EQ cexp (DCon (SYMBOL, NONE, cexp), s (CONleft, cexpright)) | 91 decl : CON SYMBOL EQ cexp (DCon (SYMBOL, NONE, cexp), s (CONleft, cexpright)) |
88 | CON SYMBOL DCOLON kind EQ cexp (DCon (SYMBOL, SOME kind, cexp), s (CONleft, cexpright)) | 92 | CON SYMBOL DCOLON kind EQ cexp (DCon (SYMBOL, SOME kind, cexp), s (CONleft, cexpright)) |
89 | LTYPE SYMBOL EQ cexp (DCon (SYMBOL, SOME (KType, s (LTYPEleft, cexpright)), cexp), | 93 | LTYPE SYMBOL EQ cexp (DCon (SYMBOL, SOME (KType, s (LTYPEleft, cexpright)), cexp), |
90 s (LTYPEleft, cexpright)) | 94 s (LTYPEleft, cexpright)) |
95 | VAL SYMBOL EQ eexp (DVal (SYMBOL, NONE, eexp), s (VALleft, eexpright)) | |
96 | VAL SYMBOL COLON cexp EQ eexp (DVal (SYMBOL, SOME cexp, eexp), s (VALleft, eexpright)) | |
91 | 97 |
92 kind : TYPE (KType, s (TYPEleft, TYPEright)) | 98 kind : TYPE (KType, s (TYPEleft, TYPEright)) |
93 | NAME (KName, s (NAMEleft, NAMEright)) | 99 | NAME (KName, s (NAMEleft, NAMEright)) |
94 | LBRACE kind RBRACE (KRecord kind, s (LBRACEleft, RBRACEright)) | 100 | LBRACE kind RBRACE (KRecord kind, s (LBRACEleft, RBRACEright)) |
95 | kind ARROW kind (KArrow (kind1, kind2), s (kind1left, kind2right)) | 101 | kind ARROW kind (KArrow (kind1, kind2), s (kind1left, kind2right)) |
102 | cexp ARROW cexp (TFun (cexp1, cexp2), s (cexp1left, cexp2right)) | 108 | cexp ARROW cexp (TFun (cexp1, cexp2), s (cexp1left, cexp2right)) |
103 | SYMBOL kcolon kind ARROW cexp (TCFun (kcolon, SYMBOL, kind, cexp), s (SYMBOLleft, cexpright)) | 109 | SYMBOL kcolon kind ARROW cexp (TCFun (kcolon, SYMBOL, kind, cexp), s (SYMBOLleft, cexpright)) |
104 | 110 |
105 | cexp PLUSPLUS cexp (CConcat (cexp1, cexp2), s (cexp1left, cexp1right)) | 111 | cexp PLUSPLUS cexp (CConcat (cexp1, cexp2), s (cexp1left, cexp1right)) |
106 | 112 |
107 | FN SYMBOL kcolon kind DARROW cexp (CAbs (kcolon, SYMBOL, kind, cexp), s (FNleft, cexpright)) | 113 | FN SYMBOL DCOLON kind DARROW cexp (CAbs (SYMBOL, kind, cexp), s (FNleft, cexpright)) |
108 | 114 |
109 | LPAREN cexp RPAREN DCOLON kind (CAnnot (cexp, kind), s (LPARENleft, RPARENright)) | 115 | LPAREN cexp RPAREN DCOLON kind (CAnnot (cexp, kind), s (LPARENleft, kindright)) |
110 | 116 |
111 kcolon : DCOLON (Explicit) | 117 kcolon : DCOLON (Explicit) |
112 | TCOLON (Implicit) | 118 | TCOLON (Implicit) |
113 | 119 |
114 cterm : LPAREN cexp RPAREN (#1 cexp, s (LPARENleft, RPARENright)) | 120 cterm : LPAREN cexp RPAREN (#1 cexp, s (LPARENleft, RPARENright)) |
128 | ident COLON cexp ([(ident, cexp)]) | 134 | ident COLON cexp ([(ident, cexp)]) |
129 | ident COLON cexp COMMA rcone ((ident, cexp) :: rcone) | 135 | ident COLON cexp COMMA rcone ((ident, cexp) :: rcone) |
130 | 136 |
131 ident : CSYMBOL (CName CSYMBOL, s (CSYMBOLleft, CSYMBOLright)) | 137 ident : CSYMBOL (CName CSYMBOL, s (CSYMBOLleft, CSYMBOLright)) |
132 | SYMBOL (CVar SYMBOL, s (SYMBOLleft, SYMBOLright)) | 138 | SYMBOL (CVar SYMBOL, s (SYMBOLleft, SYMBOLright)) |
139 | |
140 eapps : eterm (eterm) | |
141 | eapps eterm (EApp (eapps, eterm), s (eappsleft, etermright)) | |
142 | eapps LBRACK cexp RBRACK (ECApp (eapps, cexp), s (eappsleft, RBRACKright)) | |
143 | |
144 eexp : eapps (eapps) | |
145 | FN SYMBOL kcolon kind DARROW eexp (ECAbs (kcolon, SYMBOL, kind, eexp), s (FNleft, eexpright)) | |
146 | FN SYMBOL COLON cexp DARROW eexp (EAbs (SYMBOL, SOME cexp, eexp), s (FNleft, eexpright)) | |
147 | FN SYMBOL DARROW eexp (EAbs (SYMBOL, NONE, eexp), s (FNleft, eexpright)) | |
148 | |
149 | LPAREN eexp RPAREN DCOLON cexp (EAnnot (eexp, cexp), s (LPARENleft, cexpright)) | |
150 | |
151 eterm : LPAREN eexp RPAREN (#1 eexp, s (LPARENleft, RPARENright)) | |
152 | |
153 | SYMBOL (EVar SYMBOL, s (SYMBOLleft, SYMBOLright)) |