Commit 69d45578 authored by POTTIER Francois's avatar POTTIER Francois

Updated the lexer to produce an error message if a Menhir keyword

is used in an OCaml header.
parent d84bc0cc
File "keyword-in-header.mly", line 3, characters 10-12:
Error: A Menhir keyword cannot be used in an OCaml header.
%{
let x = $1
%}
%token A B
%start foo
foo: A B {}
......@@ -294,9 +294,13 @@ rule main = parse
| "%{"
{ savestart lexbuf (fun lexbuf ->
let openingpos = lexeme_end_p lexbuf in
let closingpos, _ = action true openingpos [] lexbuf in
(* TEMPORARY if keyword list nonempty, issue an error *)
HEADER (mk_stretch false openingpos closingpos [])
let closingpos, pkeywords = action true openingpos [] lexbuf in
begin match pkeywords with
| [] ->
HEADER (mk_stretch false openingpos closingpos [])
| { value = _; position = pos } :: _ ->
Error.error [pos] "A Menhir keyword cannot be used in an OCaml header."
end
) }
| "{"
{ savestart lexbuf (fun lexbuf ->
......
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