caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Weird behavior of Camlp4 Parser
@ 2011-11-24 15:22 bob zhang
  2011-11-24 15:47 ` Gabriel Scherer
  2011-11-24 16:33 ` Joel Reymont
  0 siblings, 2 replies; 5+ messages in thread
From: bob zhang @ 2011-11-24 15:22 UTC (permalink / raw)
  To: caml-list

Hi List,
I have came across a strange behavior of the camlp4 parser, (maybe not
that weird due to my limited knowledge of the parser)
The contrived mini-examples as follows :
module MGram = MakeGram(Lexer) ;;
EXTEND MGram
GLOBAL: m_expr ;
m_expr :
[[ "foo"; f -> print_endline "first"
| "foo" ; "bar"; "baz" -> print_endline "second"]
];
f : [["bar"; "baz" ]]; END;;
MGram.parse_string m_expr (Loc.mk "<string>") "foo bar baz ";;
second (** choose the second branch, maybe the token rule has a higher
priority *)

MGram.Entry.clear m_expr;;
EXTEND MGram
GLOBAL: m_expr ;
m_expr :
[[ "foo"; f -> print_endline "first"
| "foo" ; "bar"; "bax" -> print_endline "second"]
];
f : [["bar"; "baz" ]]; END;;
- : unit = ()
# MGram.parse_string m_expr (Loc.mk "<string>") "foo bar baz ";;
first (** here choose the first branch, but the token rule can consume
one token, I thought this should fail *)

Many Thanks


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-11-24 17:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-24 15:22 [Caml-list] Weird behavior of Camlp4 Parser bob zhang
2011-11-24 15:47 ` Gabriel Scherer
2011-11-24 16:08   ` bob zhang
2011-11-24 16:33 ` Joel Reymont
2011-11-24 17:31   ` bob zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).