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

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