* camlp4 parser accepts more than its grammar?
@ 2008-06-26 21:10 Jake Donham
2008-06-27 8:29 ` [Caml-list] " Nicolas Pouillard
0 siblings, 1 reply; 5+ messages in thread
From: Jake Donham @ 2008-06-26 21:10 UTC (permalink / raw)
To: caml users
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 + ;"))
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] camlp4 parser accepts more than its grammar?
2008-06-26 21:10 camlp4 parser accepts more than its grammar? Jake Donham
@ 2008-06-27 8:29 ` Nicolas Pouillard
2008-06-27 8:42 ` Till Varoquaux
0 siblings, 1 reply; 5+ messages in thread
From: Nicolas Pouillard @ 2008-06-27 8:29 UTC (permalink / raw)
To: Jake Donham; +Cc: caml-list
[-- Attachment #1: Type: text/plain, Size: 723 bytes --]
Excerpts from Jake Donham's message of Thu Jun 26 23:10:20 +0200 2008:
> 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,
Nothing wrong from you, that's a camlp4 known bug (PR#4551, PR#4513...).
> 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 + ;"))
>
--
Nicolas Pouillard aka Ertai
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 286 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] camlp4 parser accepts more than its grammar?
2008-06-27 8:29 ` [Caml-list] " Nicolas Pouillard
@ 2008-06-27 8:42 ` Till Varoquaux
2008-07-01 0:01 ` Arthur Chan
0 siblings, 1 reply; 5+ messages in thread
From: Till Varoquaux @ 2008-06-27 8:42 UTC (permalink / raw)
To: Nicolas Pouillard; +Cc: Jake Donham, caml-list
2008/6/27 Nicolas Pouillard <nicolas.pouillard@gmail.com>:
> Excerpts from Jake Donham's message of Thu Jun 26 23:10:20 +0200 2008:
>> 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,
>
> Nothing wrong from you, that's a camlp4 known bug (PR#4551, PR#4513...).
>
>> 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 + ;"))
>>
>
> --
> Nicolas Pouillard aka Ertai
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
>
Note that you might even have suprises when using the standard Ocaml
parser: I consider grammar more like a guideline then an actual
specification.
type t = A of int | false of float
Till
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-07-01 7:03 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-26 21:10 camlp4 parser accepts more than its grammar? Jake Donham
2008-06-27 8:29 ` [Caml-list] " Nicolas Pouillard
2008-06-27 8:42 ` Till Varoquaux
2008-07-01 0:01 ` Arthur Chan
2008-07-01 7:02 ` blue storm
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox