Commit 39a54d0c authored by POTTIER Francois's avatar POTTIER Francois

Re-established rule_specific_token, which allows giving a better syntax error...

Re-established rule_specific_token, which allows giving a better syntax error message when %% is missing.
parent 48ba456c
......@@ -9,8 +9,6 @@
correlate with star size and alphabet size, etc.
create separate graphs for 3 modes: --lalr, pager, --canonical
In Menhir's bootstrapped parser:
re-establish rule_specific_token?
git show 64504bd5214794dc34530f93faccd9f62f049dcf
use a canonical automaton?
* When dealing with errors, should we back up to the last shift action,
......
File "declaration-error-b.mly", line 3, characters 10-11:
Error: Ill-formed %token declaration.
Examples of well-formed declarations:
%token FOO
%token DOT SEMICOLON
%token <string> LID UID
Error: syntax error inside a declaration.
Did you perhaps forget the %% that separates declarations and rules?
......@@ -8,7 +8,7 @@ Either a declaration or %% is expected at this point.
TYPE UID
TYPE OCAMLTYPE TYPE
TYPE OCAMLTYPE UID PUBLIC
TYPE OCAMLTYPE UID PREC
TYPE OCAMLTYPE UID RPAREN
TYPE OCAMLTYPE UID LPAREN TYPE
TYPE OCAMLTYPE UID COMMA TYPE
......
......@@ -96,6 +96,17 @@ declaration:
| PARAMETER t = OCAMLTYPE
{ [ with_poss $startpos $endpos (DParameter t) ] }
/* This production recognizes tokens that are valid in the rules section,
but not in the declarations section. This is a hint that a %% was
forgotten. */
| rule_specific_token
{
Error.error (Positions.two $startpos $endpos)
"syntax error inside a declaration.\n\
Did you perhaps forget the %% that separates declarations and rules?"
}
priority_keyword:
LEFT
{ LeftAssoc }
......@@ -104,6 +115,13 @@ priority_keyword:
| NONASSOC
{ NonAssoc }
%inline rule_specific_token:
| PUBLIC
| INLINE
| COLON
| EOF
{ () }
/* ------------------------------------------------------------------------- */
/* Our lists of symbols are separated with optional commas. Order is
irrelevant. */
......
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