Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
menhir
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
12
Issues
12
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
POTTIER Francois
menhir
Commits
d1f461c9
Commit
d1f461c9
authored
Sep 26, 2015
by
POTTIER Francois
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Inlined options in parser. Slightly modified .messages file.
parent
a77cd4a7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
39 deletions
+49
-39
bench/bad/nonsense.expected
bench/bad/nonsense.expected
+2
-1
bench/bad/rule-error.expected
bench/bad/rule-error.expected
+3
-11
src/fancy-parser.mly
src/fancy-parser.mly
+2
-2
src/parserMessages.messages
src/parserMessages.messages
+42
-25
No files found.
bench/bad/nonsense.expected
View file @
d1f461c9
File "nonsense.mly", line 1, characters 47-50:
Error: Ill-formed rule.
Either a list of formal parameters or a colon is expected at this point.
Either a parenthesized, comma-delimited list of formal parameters
or a colon is expected at this point.
Examples of well-formed rules:
main: e = expr EOL { e }
expr: i = INT { i } | e1 = expr PLUS e2 = expr { e1 + e2 }
...
...
bench/bad/rule-error.expected
View file @
d1f461c9
File "rule-error.mly", line 11, characters 0-3:
Error: Ill-formed production.
A production is a sequence of producers, followed with a semantic action.
Examples of well-formed producers:
expr
option(COMMA)
separated_list(COMMA, expr)
e = expr
ds = declaration*
es = list(terminated(expr, SEMI))
es = list(e = expr SEMI { e })
xs = list(x = var { Some x } | WILDCARD { None })
Error: Either another production | ...
or a comma or a closing parenthesis
is expected at this point.
src/fancy-parser.mly
View file @
d1f461c9
...
...
@@ -206,7 +206,7 @@ optional_bar:
production_group
:
productions
=
separated_nonempty_list
(
BAR
,
production
)
action
=
ACTION
oprec2
=
precedence
?
oprec2
=
ioption
(
precedence
)
{
(* If multiple productions share a single semantic action, check
that all of them bind the same names. *)
...
...
@@ -238,7 +238,7 @@ production_group:
precedence
declaration
.
*/
production
:
producers
=
producer
*
oprec
=
precedence
?
producers
=
producer
*
oprec
=
ioption
(
precedence
)
{
producers
,
oprec
,
ParserAux
.
current_reduce_precedence
()
,
...
...
src/parserMessages.messages
View file @
d1f461c9
...
...
@@ -105,7 +105,8 @@ Examples of well-formed rules:
PERCENTPERCENT UID UID
Ill-formed rule.
Either a list of formal parameters or a colon is expected at this point.
Either a parenthesized, comma-delimited list of formal parameters
or a colon is expected at this point.
Examples of well-formed rules:
main: e = expr EOL { e }
expr: i = INT { i } | e1 = expr PLUS e2 = expr { e1 + e2 }
...
...
@@ -143,28 +144,35 @@ PERCENTPERCENT UID COLON UID TYPE
PERCENTPERCENT UID COLON LID TYPE
PERCENTPERCENT UID COLON LID EQUAL TYPE
PERCENTPERCENT UID COLON UID PLUS TYPE
PERCENTPERCENT UID COLON UID LPAREN UID TYPE
# Above: this sentence seems tricky. All we know is we have just read a
# symbol, and in front of us could be many things (comma, closing parenthesis,
# identifier, modifier, %prec keyword, etc.). We expect to reduce this to
# actual or lax_actual. Let's just back up to a safe level of abstraction and
# say this is an ill-formed production.
PERCENTPERCENT UID COLON UID LPAREN ACTION UID
# Above: another tricky case. Looking at the description of this state, it seems that
# only COMMA and RPAREN can follow here. But in fact, other tokens are
# possible, such as BAR, simply because they will NOT take us into this state.
# This is a manifestation of the fact that non-canonical automata ``reduce too
# far'' and can enter a state that they should not enter, before they detect
# the error. Again, let's back up to a safe (?) level of abstraction.
PERCENTPERCENT UID COLON LID EQUAL UID PLUS TYPE
Ill-formed production.
A production is a sequence of producers, followed with a semantic action.
Examples of well-formed producers:
expr
option(COMMA)
separated_list(COMMA, expr)
e = expr
ds = declaration*
es = list(terminated(expr, SEMI))
es = list(e = expr SEMI { e })
xs = list(x = var { Some x } | WILDCARD { None })
# The following sentences are similar, but have an open parenthesis.
# Suggesting that a parenthesis could be closed seems a safe bet. These
# sentences are otherwise tricky. In front of us could be many things (comma,
# closing parenthesis, identifier, modifier, %prec keyword, etc.). We expect
# to reduce to actual or lax_actual. Let's just back up to a safe level of
# abstraction and say this is an ill-formed production.
PERCENTPERCENT UID COLON UID LPAREN UID TYPE
PERCENTPERCENT UID COLON UID LPAREN UID STAR TYPE
PERCENTPERCENT UID COLON UID LPAREN UID LPAREN LID RPAREN TYPE
# Above two sentences: again cases where we have two different possible contexts,
# with different expectations as to what comes next. Again, let's back up.
PERCENTPERCENT UID COLON UID LPAREN LID TYPE
PERCENTPERCENT UID COLON UID LPAREN ACTION BAR TYPE
Ill-formed production.
Maybe you meant to close a parenthesis at this point?
A production is a sequence of producers, followed with a semantic action.
Examples of well-formed producers:
expr
...
...
@@ -178,6 +186,24 @@ Examples of well-formed producers:
# ----------------------------------------------------------------------------
PERCENTPERCENT UID COLON UID LPAREN ACTION UID
# In the non-canonical automaton, this is a tricky case where, looking at the
# description of the state, it seems that only COMMA and RPAREN can follow
# here. But in fact, other tokens are possible, such as BAR, simply because
# they will NOT take us into this state. In the canonical automaton, the list
# of possibilities is explicit in the lookahead sets.
PERCENTPERCENT UID COLON UID LPAREN ACTION PREC UID UID
# In the first case above, we may expect a %prec annotation, whereas in the
# second case above, we have just seen it. In the error message, we merge
# these two situations and do not mention the possibility of a %prec
# annotation.
Either another production | ...
or a comma or a closing parenthesis
is expected at this point.
# ----------------------------------------------------------------------------
PERCENTPERCENT UID COLON PREC TYPE
PERCENTPERCENT UID COLON UID LPAREN ACTION PREC TYPE
PERCENTPERCENT UID COLON ACTION PREC TYPE
...
...
@@ -257,12 +283,3 @@ Examples of well-formed actual parameters:
option(expr)
separated_list(COMMA, expr)
# ----------------------------------------------------------------------------
PERCENTPERCENT UID COLON UID LPAREN ACTION PREC UID UID
Either another production | ...
or a comma or a closing parenthesis
is expected at this point.
# Tricky.
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