Commit c781e458 authored by Yann Régis-Gianas's avatar Yann Régis-Gianas

Syntax: Every producer must be named.

   If the programmer did not provide a name [_i] is used (where [i] is
   the producer's position in the right hand side).

   This syntax modification actually simplifies the code:
   - There is no more on-the-fly naming of unnamed arguments.
   - Inlining is no more restricted to semantic actions that do not use $i.

   The patch is large because:
   - This change has an impact on many modules.
   - The expected results of the bench had to be updated.
parent 943020b3
...@@ -15,18 +15,18 @@ open Syntax.Raw ...@@ -15,18 +15,18 @@ open Syntax.Raw
%% %%
expr: expr:
| VAR | _1 = VAR
{ EVar $1 } { ( EVar _1 )}
| CONST | _1 = CONST
{ EConst $1 } { ( EConst _1 )}
| expr PLUS expr | _1 = expr _2 = PLUS _3 = expr
{ EAdd ($1, $3) } { ( EAdd (_1, _3) )}
| FAIL | _1 = FAIL
{ EFail } { ( EFail )}
declarations: declarations:
| VAR EQUAL expr EOF | _1 = VAR _2 = EQUAL _3 = expr _4 = EOF
{ D ($1, $3, Suspension.create (fun () -> !ParserFix.declarations())) } { ( D (_1, _3, Suspension.create (fun () -> !ParserFix.declarations())) )}
%% %%
......
...@@ -35,101 +35,101 @@ open Mm.Raw ...@@ -35,101 +35,101 @@ open Mm.Raw
%% %%
atomic_expression: atomic_expression:
| LIDENT | _1 = LIDENT
{ EVar $1 } { ( EVar _1 )}
| LCURLY record_fields RCURLY | _1 = LCURLY _2 = record_fields _3 = RCURLY
{ ERecord $2 } { ( ERecord _2 )}
| atomic_expression DOT LIDENT | _1 = atomic_expression _2 = DOT _3 = LIDENT
{ ERecordSelection ($1, $3) } { ( ERecordSelection (_1, _3) )}
| MIXIN components END | _1 = MIXIN _2 = components _3 = END
{ let _, input, output = $2 in { ( let _, input, output = _2 in
EStructure (input, output) } EStructure (input, output) )}
| LPAREN expression RPAREN | _1 = LPAREN _2 = expression _3 = RPAREN
{ $2 } { ( _2 )}
unary_expression: unary_expression:
| atomic_expression | _1 = atomic_expression
{ $1 } { ( _1 )}
| CLOSE unary_expression | _1 = CLOSE _2 = unary_expression
{ EClose $2 } { ( EClose _2 )}
| DELETE fields IN unary_expression | _1 = DELETE _2 = fields _3 = IN _4 = unary_expression
{ EDeletion ($4, $2) } { ( EDeletion (_4, _2) )}
| FAKE LIDENT DEPENDS ON LIDENT IN unary_expression | _1 = FAKE _2 = LIDENT _3 = DEPENDS _4 = ON _5 = LIDENT _6 = IN _7 = unary_expression
{ EFakeDependency ($7, $2, $5) } { ( EFakeDependency (_7, _2, _5) )}
summand_expression: summand_expression:
| unary_expression | _1 = unary_expression
{ $1 } { ( _1 )}
| summand_expression PLUS unary_expression | _1 = summand_expression _2 = PLUS _3 = unary_expression
{ EComposition ($1, $3) } { ( EComposition (_1, _3) )}
expression: expression:
| summand_expression | _1 = summand_expression
{ $1 } { ( _1 )}
| LET REC bindings IN expression | _1 = LET _2 = REC _3 = bindings _4 = IN _5 = expression
{ ELetRec (List.rev $3, $5) } { ( ELetRec (List.rev _3, _5) )}
bindings: bindings:
| binding | _1 = binding
{ [ $1 ] } { ( [ _1 ] )}
| bindings AND binding | _1 = bindings _2 = AND _3 = binding
{ $3 :: $1 } { ( _3 :: _1 )}
binding: binding:
| LIDENT EQUAL expression | _1 = LIDENT _2 = EQUAL _3 = expression
{ ($1, $3) } { ( (_1, _3) )}
toplevel: toplevel:
| expression EOF | _1 = expression _2 = EOF
{ $1 } { ( _1 )}
record_fields: record_fields:
| |
{ StringMap.empty } { ( StringMap.empty )}
| record_fields VAL LIDENT EQUAL expression | _1 = record_fields _2 = VAL _3 = LIDENT _4 = EQUAL _5 = expression
{ StringMap.add $3 $5 $1 } { ( StringMap.add _3 _5 _1 )}
components: components:
| |
{ 0, StringMap.empty, (StringMap.empty, []) } { ( 0, StringMap.empty, (StringMap.empty, []) )}
| components VAL lident_pun dependencies EQUAL expression | _1 = components _2 = VAL _3 = lident_pun _4 = dependencies _5 = EQUAL _6 = expression
{ let xname, iname = $3 in { ( let xname, iname = _3 in
let i, input, (fields, anonymous) = $1 in let i, input, (fields, anonymous) = _1 in
let fields = StringMap.add xname ($4, iname, $6, Mm.KStructMember i) fields in let fields = StringMap.add xname (_4, iname, _6, Mm.KStructMember i) fields in
i+1, input, (fields, anonymous) } i+1, input, (fields, anonymous) )}
| components VAL WILDCARD AS LIDENT dependencies EQUAL expression | _1 = components _2 = VAL _3 = WILDCARD _4 = AS _5 = LIDENT _6 = dependencies _7 = EQUAL _8 = expression
{ let i, input, (fields, anonymous) = $1 in { ( let i, input, (fields, anonymous) = _1 in
let anonymous = ($6, $5, $8, Mm.KStructMember i) :: anonymous in let anonymous = (_6, _5, _8, Mm.KStructMember i) :: anonymous in
i+1, input, (fields, anonymous) } i+1, input, (fields, anonymous) )}
| components VAL lident_pun | _1 = components _2 = VAL _3 = lident_pun
{ let xname, iname = $3 in { ( let xname, iname = _3 in
let i, input, output = $1 in let i, input, output = _1 in
let input = StringMap.add xname iname input in let input = StringMap.add xname iname input in
i+1, input, output } i+1, input, output )}
lident_pun: lident_pun:
| LIDENT AS LIDENT | _1 = LIDENT _2 = AS _3 = LIDENT
{ $1, $3 } { ( _1, _3 )}
| LIDENT | _1 = LIDENT
{ $1, $1 } { ( _1, _1 )}
fields: fields:
| |
{ StringSet.empty } { ( StringSet.empty )}
| fields LIDENT | _1 = fields _2 = LIDENT
{ StringSet.add $2 $1 } { ( StringSet.add _2 _1 )}
dependencies: dependencies:
| |
{ [] } { ( [] )}
| LSQUARE variables RSQUARE | _1 = LSQUARE _2 = variables _3 = RSQUARE
{ $2 } { ( _2 )}
variables: variables:
| |
{ [] } { ( [] )}
| variables LIDENT | _1 = variables _2 = LIDENT
{ $2 :: $1 } { ( _2 :: _1 )}
%% %%
......
...@@ -32,134 +32,134 @@ open Fsub.Raw ...@@ -32,134 +32,134 @@ open Fsub.Raw
%% %%
toplevel: toplevel:
| EOF | _1 = EOF
{ TopEOF } { ( TopEOF )}
| Term SEMI toplevel | _1 = Term _2 = SEMI _3 = toplevel
{ TopEval ($1, $3) } { ( TopEval (_1, _3) )}
| UCID TyBinder SEMI toplevel | _1 = UCID _2 = TyBinder _3 = SEMI _4 = toplevel
{ TopTypeBind ($1, $2, $4) } { ( TopTypeBind (_1, _2, _4) )}
| LCID Binder SEMI toplevel | _1 = LCID _2 = Binder _3 = SEMI _4 = toplevel
{ TopTermBind ($1, $2, $4) } { ( TopTermBind (_1, _2, _4) )}
Binder: Binder:
| COLON Type | _1 = COLON _2 = Type
{ $2 } { ( _2 )}
Type: Type:
| ArrowType | _1 = ArrowType
{ $1 } { ( _1 )}
| ALL UCID OType DOT Type | _1 = ALL _2 = UCID _3 = OType _4 = DOT _5 = Type
{ TForall ($2, $3, $5) } { ( TForall (_2, _3, _5) )}
AType: AType:
| LPAREN Type RPAREN | _1 = LPAREN _2 = Type _3 = RPAREN
{ $2 } { ( _2 )}
| UCID | _1 = UCID
{ TVar $1 } { ( TVar _1 )}
| TTOP | _1 = TTOP
{ TTop } { ( TTop )}
| LCURLY FieldTypes RCURLY | _1 = LCURLY _2 = FieldTypes _3 = RCURLY
{ TRecord $2 } { ( TRecord _2 )}
TyBinder: TyBinder:
| |
{ TTop } { ( TTop )}
| LEQ Type | _1 = LEQ _2 = Type
{ $2 } { ( _2 )}
ArrowType: ArrowType:
| AType ARROW ArrowType | _1 = AType _2 = ARROW _3 = ArrowType
{ TArrow ($1, $3) } { ( TArrow (_1, _3) )}
| AType | _1 = AType
{ $1 } { ( _1 )}
Term: Term:
| AppTerm | _1 = AppTerm
{ $1 } { ( _1 )}
| LAMBDA LCID COLON Type DOT Term | _1 = LAMBDA _2 = LCID _3 = COLON _4 = Type _5 = DOT _6 = Term
{ EAbs ($2, $4, $6) } { ( EAbs (_2, _4, _6) )}
| LET Pattern EQ Term IN Term | _1 = LET _2 = Pattern _3 = EQ _4 = Term _5 = IN _6 = Term
{ ELet ($2, $4, $6) } { ( ELet (_2, _4, _6) )}
| LAMBDA UCID OType DOT Term | _1 = LAMBDA _2 = UCID _3 = OType _4 = DOT _5 = Term
{ ETyAbs ($2, $3, $5) } { ( ETyAbs (_2, _3, _5) )}
AppTerm: AppTerm:
| PathTerm | _1 = PathTerm
{ $1 } { ( _1 )}
| AppTerm PathTerm | _1 = AppTerm _2 = PathTerm
{ EApp ($1, $2) } { ( EApp (_1, _2) )}
| AppTerm LSQUARE Type RSQUARE | _1 = AppTerm _2 = LSQUARE _3 = Type _4 = RSQUARE
{ ETyApp ($1, $3) } { ( ETyApp (_1, _3) )}
PathTerm: PathTerm:
| PathTerm DOT LCID | _1 = PathTerm _2 = DOT _3 = LCID
{ EProj ($1, $3) } { ( EProj (_1, _3) )}
| ATerm | _1 = ATerm
{ $1 } { ( _1 )}
FieldTypes: FieldTypes:
| |
{ StringMap.empty } { ( StringMap.empty )}
| NEFieldTypes | _1 = NEFieldTypes
{ $1 } { ( _1 )}
NEFieldTypes: NEFieldTypes:
| LCID COLON Type | _1 = LCID _2 = COLON _3 = Type
{ StringMap.singleton $1 $3 } { ( StringMap.singleton _1 _3 )}
| LCID COLON Type COMMA NEFieldTypes | _1 = LCID _2 = COLON _3 = Type _4 = COMMA _5 = NEFieldTypes
{ StringMap.add $1 $3 $5 } { ( StringMap.add _1 _3 _5 )}
TermSeq: TermSeq:
| Term | _1 = Term
{ $1 } { ( _1 )}
| Term SEMI TermSeq | _1 = Term _2 = SEMI _3 = TermSeq
{ ELet (PWildcard, $1, $3) } { ( ELet (PWildcard, _1, _3) )}
ATerm: ATerm:
| LPAREN TermSeq RPAREN | _1 = LPAREN _2 = TermSeq _3 = RPAREN
{ $2 } { ( _2 )}
| LCID | _1 = LCID
{ EVar $1 } { ( EVar _1 )}
| LCURLY Fields RCURLY | _1 = LCURLY _2 = Fields _3 = RCURLY
{ ERecord $2 } { ( ERecord _2 )}
Fields: Fields:
| |
{ StringMap.empty } { ( StringMap.empty )}
| NEFields | _1 = NEFields
{ $1 } { ( _1 )}
NEFields: NEFields:
| LCID EQ Term | _1 = LCID _2 = EQ _3 = Term
{ StringMap.singleton $1 $3 } { ( StringMap.singleton _1 _3 )}
| LCID EQ Term COMMA NEFields | _1 = LCID _2 = EQ _3 = Term _4 = COMMA _5 = NEFields
{ StringMap.add $1 $3 $5 } { ( StringMap.add _1 _3 _5 )}
OType: OType:
| |
{ TTop} { ( TTop)}
| LEQ Type | _1 = LEQ _2 = Type
{ $2 } { ( _2 )}
Pattern: Pattern:
| USCORE | _1 = USCORE
{ PWildcard } { ( PWildcard )}
| LCID COLON Type | _1 = LCID _2 = COLON _3 = Type
{ PVar ($1, $3) } { ( PVar (_1, _3) )}
| LCURLY PatFields RCURLY | _1 = LCURLY _2 = PatFields _3 = RCURLY
{ PRecord $2 } { ( PRecord _2 )}
PatFields: PatFields:
| |
{ StringMap.empty } { ( StringMap.empty )}
| NEPatFields | _1 = NEPatFields
{ $1 } { ( _1 )}
NEPatFields: NEPatFields:
| LCID EQ Pattern | _1 = LCID _2 = EQ _3 = Pattern
{ StringMap.singleton $1 $3 } { ( StringMap.singleton _1 _3 )}
| LCID EQ Pattern COMMA NEPatFields | _1 = LCID _2 = EQ _3 = Pattern _4 = COMMA _5 = NEPatFields
{ StringMap.add $1 $3 $5 } { ( StringMap.add _1 _3 _5 )}
%% %%
......
This diff is collapsed.
This diff is collapsed.
...@@ -33,102 +33,102 @@ ...@@ -33,102 +33,102 @@
%% %%
parse_io_module: parse_io_module:
| imports export decll expr Lend | _1 = imports _2 = export _3 = decll _4 = expr _5 = Lend
{ ($1,$2,$3,$4) } { ( (_1,_2,_3,_4) )}
imports: imports:
| Limport Lident importlist Lperiod imports | _1 = Limport _2 = Lident _3 = importlist _4 = Lperiod _5 = imports
{ last_pos := pos $2;(String.lowercase (unpos $2), $3)::$5 } { ( last_pos := pos _2;(String.lowercase (unpos _2), _3)::_5 )}
| |
{ [] } { ( [] )}
importlist: importlist:
| Lcolon idlist | _1 = Lcolon _2 = idlist
{ Some $2 } { ( Some _2 )}
| |
{ None } { ( None )}
export: export:
| Lexport idlist Lperiod | _1 = Lexport _2 = idlist _3 = Lperiod
{ $2 } { ( _2 )}
| |
{ [] } { ( [] )}
decll: decll:
| Ldeclare Lident Lcolon eatom Lperiod decll | _1 = Ldeclare _2 = Lident _3 = Lcolon _4 = eatom _5 = Lperiod _6 = decll
{ last_pos := pos $2;ct1 ($1,unpos $2,$4) $6 } { ( last_pos := pos _2;ct1 (_1,unpos _2,_4) _6 )}
| Lprimitive Lident Lcolon Lident Lperiod decll | _1 = Lprimitive _2 = Lident _3 = Lcolon _4 = Lident _5 = Lperiod _6 = decll
{ last_pos := pos $2;ct1 ($1,unpos $2,Eprimitive (unpos $4)) $6 } { ( last_pos := pos _2;ct1 (_1,unpos _2,Eprimitive (unpos _4)) _6 )}
| Lvariable Lident Lcolon eatom Lperiod decll | _1 = Lvariable _2 = Lident _3 = Lcolon _4 = eatom _5 = Lperiod _6 = decll
{ last_pos := pos $2;ct2 ($1,unpos $2,$4) $6 } { ( last_pos := pos _2;ct2 (_1,unpos _2,_4) _6 )}
| |
{ ([], []) } { ( ([], []) )}
expr: expr:
| Lident paramlist | _1 = Lident _2 = paramlist
{ Eappl (pos $1, unpos $1, $2, EFall) } { ( Eappl (pos _1, unpos _1, _2, EFall) )}
| Lident | _1 = Lident
{ Eid (pos $1, unpos $1) } { ( Eid (pos _1, unpos _1) )}
| Lident Lputvar patom stmttail | _1 = Lident _2 = Lputvar _3 = patom _4 = stmttail
{ Eputvar (pos $1, unpos $1, $3, $4, EFall) } { ( Eputvar (pos _1, unpos _1, _3, _4, EFall) )}
| Lident Lgetvar Lident stmttail | _1 = Lident _2 = Lgetvar _3 = Lident _4 = stmttail
{ Egetvar (pos $1, unpos $1, unpos $3, $4, EFall) } { ( Egetvar (pos _1, unpos _1, unpos _3, _4, EFall) )}
| stmt | _1 = stmt
{ $1 } { ( _1 )}
paramlist: paramlist:
| patom paramlisttail | _1 = patom _2 = paramlisttail
{ $1::$2 } { ( _1::_2 )}
| Lsemi eatom | _1 = Lsemi _2 = eatom
{ [$2] } { ( [_2] )}
| stmt | _1 = stmt
{ [$1] } { ( [_1] )}
paramlisttail: paramlisttail:
| patom paramlisttail | _1 = patom _2 = paramlisttail
{ $1::$2 } { ( _1::_2 )}
| Lsemi eatom | _1 = Lsemi _2 = eatom
{ [$2] } { ( [_2] )}
| stmt | _1 = stmt
{ [$1] } { ( [_1] )}
| |
{ [] } { ( [] )}
stmt: stmt:
| Llambda idlist stmttail | _1 = Llambda _2 = idlist _3 = stmttail
{ Elambda ($1,$2,$3,EFall) } { ( Elambda (_1,_2,_3,EFall) )}
stmttail: stmttail:
| Lsemi eatom | _1 = Lsemi _2 = eatom
{ $2 } { ( _2 )}
| atom | _1 = atom
{ $1 } { ( _1 )}
idlist: idlist:
| Lident idlist | _1 = Lident _2 = idlist
{ last_pos := pos $1;(unpos $1)::$2 } { ( last_pos := pos _1;(unpos _1)::_2 )}
| |
{ [] } { ( [] )}
eatom: eatom:
| expr | _1 = expr
{ $1 } { ( _1 )}
| atom | _1 = atom
{ $1 } { ( _1 )}
patom: patom:
| Lident | _1 = Lident
{ last_pos := pos $1; Eid (pos $1,unpos $1) } { ( last_pos := pos _1; Eid (pos _1,unpos _1) )}
| atom | _1 = atom
{ $1 } { ( _1 )}
atom: atom:
| Lint | _1 = Lint
{ last_pos := pos $1; Eint (pos $1,unpos $1) } { ( last_pos := pos _1; Eint (pos _1,unpos _1) )}
| Lstring | _1 = Lstring
{ last_pos := pos $1; Estring (pos $1,unpos $1) } { ( last_pos := pos _1; Estring (pos _1,unpos _1) )}
| Llpar expr Lrpar | _1 = Llpar _2 = expr _3 = Lrpar
{ $2 } { ( _2 )}
%% %%
......
...@@ -11,41 +11,41 @@ recommend switching on --infer in order to avoid obscure type error messages. ...@@ -11,41 +11,41 @@ recommend switching on --infer in order to avoid obscure type error messages.
%% %%
phrase: phrase:
| xs = list___anonymous_0_ ys = list___anonymous_1_ EOF | xs = list___anonymous_0_ ys = list___anonymous_1_ _3 = EOF
{ xs @ ys } { ( xs @ ys )}
list___anonymous_1_: list___anonymous_1_:
| |
{ [] } { ( [] )}
| x0 = D y0 = D xs = list___anonymous_1_ | x0 = D y0 = D xs = list___anonymous_1_
{let x = {let x =
let y = y0 in let y = y0 in
let x = x0 in let x = x0 in
( x + y ) ( ( x + y ))
in in
x :: xs } ( x :: xs )}
list___anonymous_0_: list___anonymous_0_:
| |