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
4986f5ca
Commit
4986f5ca
authored
Nov 04, 2015
by
POTTIER Francois
Browse files
More complex grammar in quicktest/positions/.
parent
a1bc99d2
Changes
6
Hide whitespace changes
Inline
Side-by-side
quicktest/positions/02.in
0 → 100644
View file @
4986f5ca
, (1 + 2 * 10) * 2
quicktest/positions/03.in
0 → 100644
View file @
4986f5ca
. , (1 + 2 * 10) * 2
quicktest/positions/04.in
0 → 100644
View file @
4986f5ca
( . , (1 + 2 * 10) * 2) - . (2)
quicktest/positions/lexer.mll
View file @
4986f5ca
...
...
@@ -46,6 +46,8 @@ and token = parse
{
RPAREN
}
|
'.'
{
DOT
}
|
'
,
'
{
COMMA
}
|
_
{
raise
(
Error
(
Printf
.
sprintf
"At offset %d: unexpected character.
\n
"
(
Lexing
.
lexeme_start
lexbuf
)))
}
quicktest/positions/parser-menhir.mly
View file @
4986f5ca
...
...
@@ -2,7 +2,7 @@
%
token
PLUS
MINUS
TIMES
DIV
%
token
LPAREN
RPAREN
%
token
EOL
%
token
DOT
%
token
DOT
COMMA
%
left
PLUS
MINUS
/*
lowest
precedence
*/
%
left
TIMES
DIV
/*
medium
precedence
*/
...
...
@@ -27,12 +27,21 @@ optional_dot:
|
DOT
{
Aux
.
print
"optional_dot"
$
startpos
$
endpos
}
optional_comma
:
|
nothing
|
COMMA
{
Aux
.
print
"optional_comma"
$
startpos
$
endpos
}
annotations
:
optional_dot
optional_comma
{
Aux
.
print
"annotations"
$
startpos
$
endpos
}
%
inline
operator
:
PLUS
|
MINUS
|
TIMES
|
DIV
{}
raw_expr
:
|
INT
|
optional_dot
LPAREN
nothing
expr
RPAREN
optional_dot
|
annotations
LPAREN
nothing
expr
RPAREN
optional_dot
|
expr
operator
expr
|
MINUS
expr
%
prec
UMINUS
{}
...
...
quicktest/positions/parser-ocamlyacc.mly
View file @
4986f5ca
...
...
@@ -2,7 +2,7 @@
%
token
PLUS
MINUS
TIMES
DIV
%
token
LPAREN
RPAREN
%
token
EOL
%
token
DOT
%
token
DOT
COMMA
%
left
PLUS
MINUS
/*
lowest
precedence
*/
%
left
TIMES
DIV
/*
medium
precedence
*/
...
...
@@ -29,10 +29,20 @@ optional_dot:
|
DOT
{
Aux
.
print
"optional_dot"
(
Parsing
.
symbol_start_pos
()
)
(
Parsing
.
symbol_end_pos
()
)}
optional_comma
:
|
nothing
{
Aux
.
print
"optional_comma"
(
Parsing
.
symbol_start_pos
()
)
(
Parsing
.
symbol_end_pos
()
)}
|
COMMA
{
Aux
.
print
"optional_comma"
(
Parsing
.
symbol_start_pos
()
)
(
Parsing
.
symbol_end_pos
()
)}
annotations
:
optional_dot
optional_comma
{
Aux
.
print
"annotations"
(
Parsing
.
symbol_start_pos
()
)
(
Parsing
.
symbol_end_pos
()
)}
raw_expr
:
|
INT
{}
|
optional_dot
LPAREN
nothing
expr
RPAREN
optional_dot
|
annotations
LPAREN
nothing
expr
RPAREN
optional_dot
{}
|
expr
PLUS
expr
{}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment