Commit d1f461c9 authored by POTTIER Francois's avatar POTTIER Francois

Inlined options in parser. Slightly modified .messages file.

parent a77cd4a7
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 }
......
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.
......@@ -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(),
......
......@@ -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.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment