comparison src/lacweb.grm @ 123:e3041657d653

Parsing and elaborating (non-mutual) 'val rec'
author Adam Chlipala <adamc@hcoop.net>
date Thu, 17 Jul 2008 10:09:34 -0400
parents 3739af9e727a
children 5df655503288
comparison
equal deleted inserted replaced
122:f7c6ceb87bbd 123:e3041657d653
42 | STRING of string | INT of Int64.int | FLOAT of Real64.real 42 | STRING of string | INT of Int64.int | FLOAT of Real64.real
43 | SYMBOL of string | CSYMBOL of string 43 | SYMBOL of string | CSYMBOL of string
44 | LPAREN | RPAREN | LBRACK | RBRACK | LBRACE | RBRACE 44 | LPAREN | RPAREN | LBRACK | RBRACK | LBRACE | RBRACE
45 | EQ | COMMA | COLON | DCOLON | TCOLON | DOT | HASH | UNDER | UNDERUNDER 45 | EQ | COMMA | COLON | DCOLON | TCOLON | DOT | HASH | UNDER | UNDERUNDER
46 | DIVIDE | GT 46 | DIVIDE | GT
47 | CON | LTYPE | VAL | FOLD | UNIT | KUNIT 47 | CON | LTYPE | VAL | REC | AND | FOLD | UNIT | KUNIT
48 | TYPE | NAME 48 | TYPE | NAME
49 | ARROW | LARROW | DARROW 49 | ARROW | LARROW | DARROW
50 | FN | PLUSPLUS | DOLLAR | TWIDDLE 50 | FN | PLUSPLUS | DOLLAR | TWIDDLE
51 | STRUCTURE | SIGNATURE | STRUCT | SIG | END | FUNCTOR | WHERE | EXTERN 51 | STRUCTURE | SIGNATURE | STRUCT | SIG | END | FUNCTOR | WHERE | EXTERN
52 | INCLUDE | OPEN | CONSTRAINT | CONSTRAINTS | EXPORT 52 | INCLUDE | OPEN | CONSTRAINT | CONSTRAINTS | EXPORT
57 57
58 %nonterm 58 %nonterm
59 file of decl list 59 file of decl list
60 | decls of decl list 60 | decls of decl list
61 | decl of decl 61 | decl of decl
62 | vali of string * con option * exp
63 | valis of (string * con option * exp) list
62 64
63 | sgn of sgn 65 | sgn of sgn
64 | sgntm of sgn 66 | sgntm of sgn
65 | sgi of sgn_item 67 | sgi of sgn_item
66 | sgis of sgn_item list 68 | sgis of sgn_item list
123 125
124 decl : CON SYMBOL EQ cexp (DCon (SYMBOL, NONE, cexp), s (CONleft, cexpright)) 126 decl : CON SYMBOL EQ cexp (DCon (SYMBOL, NONE, cexp), s (CONleft, cexpright))
125 | CON SYMBOL DCOLON kind EQ cexp (DCon (SYMBOL, SOME kind, cexp), s (CONleft, cexpright)) 127 | CON SYMBOL DCOLON kind EQ cexp (DCon (SYMBOL, SOME kind, cexp), s (CONleft, cexpright))
126 | LTYPE SYMBOL EQ cexp (DCon (SYMBOL, SOME (KType, s (LTYPEleft, cexpright)), cexp), 128 | LTYPE SYMBOL EQ cexp (DCon (SYMBOL, SOME (KType, s (LTYPEleft, cexpright)), cexp),
127 s (LTYPEleft, cexpright)) 129 s (LTYPEleft, cexpright))
128 | VAL SYMBOL EQ eexp (DVal (SYMBOL, NONE, eexp), s (VALleft, eexpright)) 130 | VAL vali (DVal vali, s (VALleft, valiright))
129 | VAL SYMBOL COLON cexp EQ eexp (DVal (SYMBOL, SOME cexp, eexp), s (VALleft, eexpright)) 131 | VAL REC valis (DValRec valis, s (VALleft, valisright))
130 132
131 | SIGNATURE CSYMBOL EQ sgn (DSgn (CSYMBOL, sgn), s (SIGNATUREleft, sgnright)) 133 | SIGNATURE CSYMBOL EQ sgn (DSgn (CSYMBOL, sgn), s (SIGNATUREleft, sgnright))
132 | STRUCTURE CSYMBOL EQ str (DStr (CSYMBOL, NONE, str), s (STRUCTUREleft, strright)) 134 | STRUCTURE CSYMBOL EQ str (DStr (CSYMBOL, NONE, str), s (STRUCTUREleft, strright))
133 | STRUCTURE CSYMBOL COLON sgn EQ str (DStr (CSYMBOL, SOME sgn, str), s (STRUCTUREleft, strright)) 135 | STRUCTURE CSYMBOL COLON sgn EQ str (DStr (CSYMBOL, SOME sgn, str), s (STRUCTUREleft, strright))
134 | FUNCTOR CSYMBOL LPAREN CSYMBOL COLON sgn RPAREN EQ str 136 | FUNCTOR CSYMBOL LPAREN CSYMBOL COLON sgn RPAREN EQ str
147 [] => raise Fail "Impossible mpath parse [3]" 149 [] => raise Fail "Impossible mpath parse [3]"
148 | m :: ms => (DOpenConstraints (m, ms), s (OPENleft, mpathright))) 150 | m :: ms => (DOpenConstraints (m, ms), s (OPENleft, mpathright)))
149 | CONSTRAINT cterm TWIDDLE cterm (DConstraint (cterm1, cterm2), s (CONSTRAINTleft, ctermright)) 151 | CONSTRAINT cterm TWIDDLE cterm (DConstraint (cterm1, cterm2), s (CONSTRAINTleft, ctermright))
150 | EXPORT spath (DExport spath, s (EXPORTleft, spathright)) 152 | EXPORT spath (DExport spath, s (EXPORTleft, spathright))
151 153
154 vali : SYMBOL EQ eexp (SYMBOL, NONE, eexp)
155 | SYMBOL COLON cexp EQ eexp (SYMBOL, SOME cexp, eexp)
156
157 valis : vali ([vali])
158 | vali AND valis (vali :: valis)
159
152 sgn : sgntm (sgntm) 160 sgn : sgntm (sgntm)
153 | FUNCTOR LPAREN CSYMBOL COLON sgn RPAREN COLON sgn 161 | FUNCTOR LPAREN CSYMBOL COLON sgn RPAREN COLON sgn
154 (SgnFun (CSYMBOL, sgn1, sgn2), s (FUNCTORleft, sgn2right)) 162 (SgnFun (CSYMBOL, sgn1, sgn2), s (FUNCTORleft, sgn2right))
155 163
156 sgntm : SIG sgis END (SgnConst sgis, s (SIGleft, ENDright)) 164 sgntm : SIG sgis END (SgnConst sgis, s (SIGleft, ENDright))