Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
POTTIER Francois
menhir
Commits
6457e102
Commit
6457e102
authored
Jul 06, 2015
by
POTTIER Francois
Browse files
Merge branch 'master' into coverage
parents
d10e556d
ab0a7cf5
Changes
188
Expand all
Hide whitespace changes
Inline
Side-by-side
CHANGES
View file @
6457e102
2015/06/29:
Changed the treatment of the positional keywords $i. They are now
rewritten into variables of the form '_i' where 'i' is an integer.
Users are advised not to use variables of this form inside semantic
actions.
2015/02/11:
Added support for anonymous rules. This allows writing, e.g.,
list(e = expression SEMI { e })
...
...
TODO
View file @
6457e102
* Check that non-terminals begin with a lowercase letter (Maxime Dénès).
* BUG: --infer does not work when a non-terminal begins
with a lowercase letter (Maxime Dénès).
* bench/Makefile no longer works on my Mac? (egrep problem)
* Document anonymous rules.
Produce well-chosen (predictable) names for anonymous rules.
...
...
bench/bad/producer-with-a-positional-name.mly
0 → 100644
View file @
6457e102
%
start
<
unit
>
s
%
token
A
%%
s
:
A
_1
=
A
{
()
}
bench/good/alphaCaml-demos-interactive.opp.exp
View file @
6457e102
...
...
@@ -15,18 +15,18 @@ open Syntax.Raw
%%
expr:
| VAR
{ EVar
$
1 }
| CONST
{ EConst
$
1 }
|
expr PLUS
expr
{ EAdd (
$
1,
$
3) }
| FAIL
{ EFail }
|
_1 =
VAR
{
(
EVar
_
1
)
}
|
_1 =
CONST
{
(
EConst
_
1
)
}
|
_1 = expr _2 = PLUS _3 =
expr
{
(
EAdd (
_
1,
_
3)
)
}
|
_1 =
FAIL
{
(
EFail
)
}
declarations:
|
VAR EQUAL expr
EOF
{ D (
$
1,
$
3, Suspension.create (fun () -> !ParserFix.declarations())) }
|
_1 = VAR _2 = EQUAL _3 = expr _4 =
EOF
{
(
D (
_
1,
_
3, Suspension.create (fun () -> !ParserFix.declarations()))
)
}
%%
...
...
bench/good/alphaCaml-demos-mixins.opp.exp
View file @
6457e102
...
...
@@ -35,101 +35,101 @@ open Mm.Raw
%%
atomic_expression:
| LIDENT
{ EVar
$
1 }
| LCURLY record_fields RCURLY
{ ERecord
$
2 }
| atomic_expression
DOT
LIDENT
{ ERecordSelection (
$
1,
$
3) }
| MIXIN components END
{ let _, input, output =
$
2 in
EStructure (input, output) }
| LPAREN expression RPAREN
{
$
2 }
|
_1 =
LIDENT
{
(
EVar
_
1
)
}
|
_1 =
LCURLY
_2 =
record_fields
_3 =
RCURLY
{
(
ERecord
_
2
)
}
|
_1 =
atomic_expression
_2 = DOT _3 =
LIDENT
{
(
ERecordSelection (
_
1,
_
3)
)
}
|
_1 =
MIXIN
_2 =
components
_3 =
END
{
(
let _, input, output =
_
2 in
EStructure (input, output)
)
}
|
_1 =
LPAREN
_2 =
expression
_3 =
RPAREN
{
( _
2
)
}
unary_expression:
| atomic_expression
{
$
1 }
|
CLOSE
unary_expression
{ EClose
$
2 }
| DELETE fields
IN
unary_expression
{ EDeletion (
$
4,
$
2) }
|
FAKE
LIDENT DEPENDS
ON LIDENT IN
unary_expression
{ EFakeDependency (
$
7,
$
2,
$
5) }
|
_1 =
atomic_expression
{
( _
1
)
}
|
_1 = CLOSE _2 =
unary_expression
{
(
EClose
_
2
)
}
|
_1 =
DELETE
_2 =
fields
_3 = IN _4 =
unary_expression
{
(
EDeletion (
_
4,
_
2)
)
}
|
_1 = FAKE _2 =
LIDENT
_3 =
DEPENDS
_4 = ON _5 = LIDENT _6 = IN _7 =
unary_expression
{
(
EFakeDependency (
_
7,
_
2,
_
5)
)
}
summand_expression:
| unary_expression
{
$
1 }
| summand_expression
PLUS
unary_expression
{ EComposition (
$
1,
$
3) }
|
_1 =
unary_expression
{
( _
1
)
}
|
_1 =
summand_expression
_2 = PLUS _3 =
unary_expression
{
(
EComposition (
_
1,
_
3)
)
}
expression:
| summand_expression
{
$
1 }
|
LET REC bindings IN
expression
{ ELetRec (List.rev
$
3,
$
5) }
|
_1 =
summand_expression
{
( _
1
)
}
|
_1 = LET _2 = REC _3 = bindings _4 = IN _5 =
expression
{
(
ELetRec (List.rev
_
3,
_
5)
)
}
bindings:
| binding
{ [
$
1 ] }
| bindings
AND
binding
{
$
3 ::
$
1 }
|
_1 =
binding
{
(
[
_
1 ]
)
}
|
_1 =
bindings
_2 = AND _3 =
binding
{
( _
3 ::
_
1
)
}
binding:
| LIDENT
EQUAL
expression
{
($
1,
$
3) }
|
_1 =
LIDENT
_2 = EQUAL _3 =
expression
{
( (_
1,
_
3)
)
}
toplevel:
| expression EOF
{
$
1 }
|
_1 =
expression
_2 =
EOF
{
( _
1
)
}
record_fields:
|
{ StringMap.empty }
| record_fields
VAL LIDENT EQUAL
expression
{ StringMap.add
$
3
$
5
$
1 }
{
(
StringMap.empty
)
}
|
_1 =
record_fields
_2 = VAL _3 = LIDENT _4 = EQUAL _5 =
expression
{
(
StringMap.add
_
3
_
5
_
1
)
}
components:
|
{ 0, StringMap.empty, (StringMap.empty, []) }
| components
VAL
lident_pun dependencies
EQUAL
expression
{ let xname, iname =
$
3 in
let i, input, (fields, anonymous) =
$
1 in
let fields = StringMap.add xname (
$
4, iname,
$
6, Mm.KStructMember i) fields in
i+1, input, (fields, anonymous) }
| components
VAL WILDCARD AS
LIDENT dependencies
EQUAL
expression
{ let i, input, (fields, anonymous) =
$
1 in
let anonymous = (
$
6,
$
5,
$
8, Mm.KStructMember i) :: anonymous in
i+1, input, (fields, anonymous) }
| components
VAL
lident_pun
{ let xname, iname =
$
3 in
let i, input, output =
$
1 in
{
(
0, StringMap.empty, (StringMap.empty, [])
)
}
|
_1 =
components
_2 = VAL _3 =
lident_pun
_4 =
dependencies
_5 = EQUAL _6 =
expression
{
(
let xname, iname =
_
3 in
let i, input, (fields, anonymous) =
_
1 in
let fields = StringMap.add xname (
_
4, iname,
_
6, Mm.KStructMember i) fields in
i+1, input, (fields, anonymous)
)
}
|
_1 =
components
_2 = VAL _3 = WILDCARD _4 = AS _5 =
LIDENT
_6 =
dependencies
_7 = EQUAL _8 =
expression
{
(
let i, input, (fields, anonymous) =
_
1 in
let anonymous = (
_
6,
_
5,
_
8, Mm.KStructMember i) :: anonymous in
i+1, input, (fields, anonymous)
)
}
|
_1 =
components
_2 = VAL _3 =
lident_pun
{
(
let xname, iname =
_
3 in
let i, input, output =
_
1 in
let input = StringMap.add xname iname input in
i+1, input, output }
i+1, input, output
)
}
lident_pun:
| LIDENT
AS
LIDENT
{
$
1,
$
3 }
| LIDENT
{
$
1,
$
1 }
|
_1 =
LIDENT
_2 = AS _3 =
LIDENT
{
( _
1,
_
3
)
}
|
_1 =
LIDENT
{
( _
1,
_
1
)
}
fields:
|
{ StringSet.empty }
| fields LIDENT
{ StringSet.add
$
2
$
1 }
{
(
StringSet.empty
)
}
|
_1 =
fields
_2 =
LIDENT
{
(
StringSet.add
_
2
_
1
)
}
dependencies:
|
{ [] }
| LSQUARE variables RSQUARE
{
$
2 }
{
(
[]
)
}
|
_1 =
LSQUARE
_2 =
variables
_3 =
RSQUARE
{
( _
2
)
}
variables:
|
{ [] }
| variables LIDENT
{
$
2 ::
$
1 }
{
(
[]
)
}
|
_1 =
variables
_2 =
LIDENT
{
( _
2 ::
_
1
)
}
%%
...
...
bench/good/alphaCaml-demos-poplmark.opp.exp
View file @
6457e102
...
...
@@ -32,134 +32,134 @@ open Fsub.Raw
%%
toplevel:
| EOF
{ TopEOF }
|
Term SEMI
toplevel
{ TopEval (
$
1,
$
3) }
|
UCID TyBinder SEMI
toplevel
{ TopTypeBind (
$
1,
$
2,
$
4) }
|
LCID Binder SEMI
toplevel
{ TopTermBind (
$
1,
$
2,
$
4) }
|
_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)
)
}
Binder:
|
COLON
Type
{
$
2 }
|
_1 = COLON _2 =
Type
{
( _
2
)
}
Type:
| ArrowType
{
$
1 }
|
ALL UCID OType DOT
Type
{ TForall (
$
2,
$
3,
$
5) }
|
_1 =
ArrowType
{
( _
1
)
}
|
_1 = ALL _2 = UCID _3 = OType _4 = DOT _5 =
Type
{
(
TForall (
_
2,
_
3,
_
5)
)
}
AType:
| LPAREN
Type
RPAREN
{
$
2 }
| UCID
{ TVar
$
1 }
| TTOP
{ TTop }
| LCURLY FieldTypes RCURLY
{ TRecord
$
2 }
|
_1 =
LPAREN
_2 = Type _3 =
RPAREN
{
( _
2
)
}
|
_1 =
UCID
{
(
TVar
_
1
)
}
|
_1 =
TTOP
{
(
TTop
)
}
|
_1 =
LCURLY
_2 =
FieldTypes
_3 =
RCURLY
{
(
TRecord
_
2
)
}
TyBinder:
|
{ TTop }
|
LEQ
Type
{
$
2 }
{
(
TTop
)
}
|
_1 = LEQ _2 =
Type
{
( _
2
)
}
ArrowType:
| AType
ARROW
ArrowType
{ TArrow (
$
1,
$
3) }
| AType
{
$
1 }
|
_1 =
AType
_2 = ARROW _3 =
ArrowType
{
(
TArrow (
_
1,
_
3)
)
}
|
_1 =
AType
{
( _
1
)
}
Term:
| AppTerm
{
$
1 }
| LAMBDA
LCID COLON Type DOT
Term
{ EAbs (
$
2,
$
4,
$
6) }
|
LET Pattern EQ Term IN
Term
{ ELet (
$
2,
$
4,
$
6) }
| LAMBDA
UCID OType DOT
Term
{ ETyAbs (
$
2,
$
3,
$
5) }
|
_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)
)
}
AppTerm:
| PathTerm
{
$
1 }
| AppTerm PathTerm
{ EApp (
$
1,
$
2) }
| AppTerm LSQUARE
Type
RSQUARE
{ ETyApp (
$
1,
$
3) }
|
_1 =
PathTerm
{
( _
1
)
}
|
_1 =
AppTerm
_2 =
PathTerm
{
(
EApp (
_
1,
_
2)
)
}
|
_1 =
AppTerm
_2 =
LSQUARE
_3 = Type _4 =
RSQUARE
{
(
ETyApp (
_
1,
_
3)
)
}
PathTerm:
| PathTerm
DOT
LCID
{ EProj (
$
1,
$
3) }
| ATerm
{
$
1 }
|
_1 =
PathTerm
_2 = DOT _3 =
LCID
{
(
EProj (
_
1,
_
3)
)
}
|
_1 =
ATerm
{
( _
1
)
}
FieldTypes:
|
{ StringMap.empty }
| NEFieldTypes
{
$
1 }
{
(
StringMap.empty
)
}
|
_1 =
NEFieldTypes
{
( _
1
)
}
NEFieldTypes:
|
LCID COLON
Type
{ StringMap.singleton
$
1
$
3 }
|
LCID COLON Type COMMA
NEFieldTypes
{ StringMap.add
$
1
$
3
$
5 }
|
_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
)
}
TermSeq:
| Term
{
$
1 }
|
Term SEMI
TermSeq
{ ELet (PWildcard,
$
1,
$
3) }
|
_1 =
Term
{
( _
1
)
}
|
_1 = Term _2 = SEMI _3 =
TermSeq
{
(
ELet (PWildcard,
_
1,
_
3)
)
}
ATerm:
| LPAREN TermSeq RPAREN
{
$
2 }
| LCID
{ EVar
$
1 }
| LCURLY Fields RCURLY
{ ERecord
$
2 }
|
_1 =
LPAREN
_2 =
TermSeq
_3 =
RPAREN
{
( _
2
)
}
|
_1 =
LCID
{
(
EVar
_
1
)
}
|
_1 =
LCURLY
_2 =
Fields
_3 =
RCURLY
{
(
ERecord
_
2
)
}
Fields:
|
{ StringMap.empty }
| NEFields
{
$
1 }
{
(
StringMap.empty
)
}
|
_1 =
NEFields
{
( _
1
)
}
NEFields:
|
LCID EQ
Term
{ StringMap.singleton
$
1
$
3 }
|
LCID EQ Term COMMA
NEFields
{ StringMap.add
$
1
$
3
$
5 }
|
_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
)
}
OType:
|
{ TTop}
|
LEQ
Type
{
$
2 }
{
(
TTop
)
}
|
_1 = LEQ _2 =
Type
{
( _
2
)
}
Pattern:
| USCORE
{ PWildcard }
|
LCID COLON
Type
{ PVar (
$
1,
$
3) }
| LCURLY PatFields RCURLY
{ PRecord
$
2 }
|
_1 =
USCORE
{
(
PWildcard
)
}
|
_1 = LCID _2 = COLON _3 =
Type
{
(
PVar (
_
1,
_
3)
)
}
|
_1 =
LCURLY
_2 =
PatFields
_3 =
RCURLY
{
(
PRecord
_
2
)
}
PatFields:
|
{ StringMap.empty }
| NEPatFields
{
$
1 }
{
(
StringMap.empty
)
}
|
_1 =
NEPatFields
{
( _
1
)
}
NEPatFields:
|
LCID EQ
Pattern
{ StringMap.singleton
$
1
$
3 }
|
LCID EQ Pattern COMMA
NEPatFields
{ StringMap.add
$
1
$
3
$
5 }
|
_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
)
}
%%
...
...
bench/good/alphaCaml.opp.exp
View file @
6457e102
...
...
@@ -56,234 +56,234 @@ open Syntax
%%
typevar:
|
QUOTE
LID
{
$
2 }
|
_1 = QUOTE _2 =
LID
{
( _
2
)
}
typevars:
| typevar
{ [
$
1 ] }
| typevars
COMMA
typevar
{
$
3 ::
$
1 }
|
_1 =
typevar
{
(
[
_
1 ]
)
}
|
_1 =
typevars
_2 = COMMA _3 =
typevar
{
( _
3 ::
_
1
)
}
params:
|
{ [] }
| typevar
{ [
$
1 ] }
| LPAREN typevars RPAREN
{ List.rev
$
2 }
{
(
[]
)
}
|
_1 =
typevar
{
(
[
_
1 ]
)
}
|
_1 =
LPAREN
_2 =
typevars
_3 =
RPAREN
{
(
List.rev
_
2
)
}
params_and_set_current:
| params
{ let params =
$
1 in
|
_1 =
params
{
(
let params =
_
1 in
current_params := params;
params }
params
)
}
identifier:
| LID
{
$
1 }
|
UID DOT
identifier
{ let (pos1, _, id1) =
$
1
and (_, pos2, id2) =
$
3 in
(pos1, pos2, id1 ^ "." ^ id2) }
|
_1 =
LID
{
( _
1
)
}
|
_1 = UID _2 = DOT _3 =
identifier
{
(
let (pos1, _, id1) =
_
1
and (_, pos2, id2) =
_
3 in
(pos1, pos2, id1 ^ "." ^ id2)
)
}
container:
|
{ None }
| identifier
{ Some
$
1 }
{
(
None
)
}
|
_1 =
identifier
{
(
Some
_
1
)
}
expfactor:
|
ATOM
LID
{ EAtom
$
2 }
| OCAML
{ EEscape
$
1 }
| params
LID
container
{ ETypRef (
$
3,
$
1,
$
2) }
| LANGLE params
LID
RANGLE
{ EAbstraction (
$
2,
$
3) }
| LANGLE LPAREN
LID BINDS sorts
RPAREN patrhs RANGLE
{ inline_defs := DeclPatType (!current_params,
$
3,
$
5,
$
7) :: !inline_defs;
EAbstraction (!current_params,
$
3) }
|
ATOM
error
{ error 2 "\"atom\" should be followed by a sort (a lowercase identifier)" }
| LANGLE error
{ error 2 "The contents of an abstraction should be either\n\
|
_1 = ATOM _2 =
LID
{
(
EAtom
_
2
)
}
|
_1 =
OCAML
{
(
EEscape
_
1
)
}
|
_1 =
params
_2 = LID _3 =
container
{
(
ETypRef (
_
3,
_
1,
_
2)
)
}
|
_1 =
LANGLE
_2 =
params
_3 = LID _4 =
RANGLE
{
(
EAbstraction (
_
2,
_
3)
)
}
|
_1 =
LANGLE
_2 =
LPAREN
_3 = LID _4 = BINDS _5 = sorts _6 =
RPAREN
_7 =
patrhs
_8 =
RANGLE
{
(
inline_defs := DeclPatType (!current_params,
_
3,
_
5,
_
7) :: !inline_defs;
EAbstraction (!current_params,
_
3)
)
}
|
_1 = ATOM _2 =
error
{
(
error 2 "\"atom\" should be followed by a sort (a lowercase identifier)"
)
}
|
_1 =
LANGLE
_2 =
error
{
(
error 2 "The contents of an abstraction should be either\n\
a (possibly parameterized) pattern type identifier or\n\
an inline pattern type definition." }
| INNER
{ error 1 "\"inner\" does not make sense in an expression type." }
| OUTER
{ error 1 "\"outer\" does not make sense in an expression type." }
| NEUTRAL
{ error 1 "\"neutral\" does not make sense in an expression type." }
| error
{ error 1 "Invalid expression factor." }
an inline pattern type definition."
)
}
|
_1 =
INNER
{
(
error 1 "\"inner\" does not make sense in an expression type."
)
}
|
_1 =
OUTER
{
(
error 1 "\"outer\" does not make sense in an expression type."
)
}
|
_1 =
NEUTRAL
{
(
error 1 "\"neutral\" does not make sense in an expression type."
)
}
|
_1 =
error
{
(
error 1 "Invalid expression factor."
)
}
patfactor:
|
ATOM
LID
{ PAtom
$
2 }
| OCAML
{ PEscape
$
1 }
| params
LID
container
{ PTypRef (MRef,
$
3,
$
1,
$
2) }
| patmodifier params
LID
container
{ PTypRef (
$
1,
$
4,
$
2,
$
3) }
|
ATOM
error
{ error 2 "\"atom\" should be followed by a sort (a lowercase identifier)" }
| patmodifier error
{ error 2 "\"inner\", \"outer\", and \"neutral\" should be followed by a\n(possibly parameterized) type identifier." }
| LANGLE
{ error 1 "An abstraction does not make sense in a pattern type." }
| error
{ error 1 "Invalid pattern factor." }
|
_1 = ATOM _2 =
LID
{
(
PAtom
_
2
)
}
|
_1 =
OCAML
{
(
PEscape
_
1
)
}
|
_1 =
params
_2 = LID _3 =
container
{
(
PTypRef (MRef,
_
3,
_
1,
_
2)
)
}
|
_1 =
patmodifier
_2 =
params
_3 = LID _4 =
container
{
(
PTypRef (
_
1,
_
4,
_
2,
_
3)
)
}
|
_1 = ATOM _2 =
error
{
(
error 2 "\"atom\" should be followed by a sort (a lowercase identifier)"
)
}
|
_1 =
patmodifier
_2 =
error
{
(
error 2 "\"inner\", \"outer\", and \"neutral\" should be followed by a\n(possibly parameterized) type identifier."
)
}
|
_1 =
LANGLE
{
(
error 1 "An abstraction does not make sense in a pattern type."
)
}
|
_1 =
error
{
(
error 1 "Invalid pattern factor."
)
}
patmodifier:
| INNER
{ MInner }
| OUTER
{ MOuter }
| NEUTRAL
{ MNeutral }
|
_1 =
INNER
{
(
MInner
)
}
|
_1 =
OUTER
{
(
MOuter
)
}
|
_1 =
NEUTRAL
{
(
MNeutral
)
}
expfactors:
| expfactor
{ [ (None,
$
1) ] }
| expfactors
STAR
expfactor
{ (None,
$
3) ::
$
1 }
| expfactors error
{ error 2 "Undetermined syntax error." }
|
_1 =
expfactor
{
(
[ (None,
_
1) ]
)
}
|
_1 =
expfactors
_2 = STAR _3 =
expfactor
{
(
(None,
_
3) ::
_
1
)
}
|
_1 =
expfactors
_2 =
error
{
(
error 2 "Undetermined syntax error."
)
}