Browse thread
camlp4 parser accepts more than its grammar?
- Jake Donham
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Jake Donham <jake@d...> |
| Subject: | camlp4 parser accepts more than its grammar? |
Hi list,
I expected the following program to fail with a parse error, but it
happily ignores the extra '+'. I would be grateful if someone could
point out what I'm doing wrong. Thanks,
Jake
open Camlp4.PreCast;;
let expr = Gram.Entry.mk "expr";;
let stmt = Gram.Entry.mk "stmt";;
EXTEND Gram
expr: [[
x = expr; "+"; y = expr -> x + y
| x = INT -> int_of_string x
]];
stmt:
[[ e = expr; ";"; `EOI -> e ]];
END;;
prerr_endline (string_of_int (Gram.parse_string stmt Loc.ghost "2 + 1 + ;"))