OCaml analyzer and grammar structure

I am developing a parser for a tiny language whose syntax is as follows

P::= 1 | 0 | P+P | P and P | P wait(d) P 

Here is the code I wrote in Ocaml camlp4

 action: [ ["act"; a = LIDENT -> Act(a)] | ["coact"; a = LIDENT -> Act2(a)] ]; proc: [ [ "ZERO" -> Zero] | RIGHTA ["."; l = action; p = SELF -> Now(l,p)] | RIGHTA [":"; l = action; p = SELF -> Delay(l,p)] | LEFTA [p1 = SELF; "+"; p2 = SELF -> Plus(p1,p2)] |RIGHTA [p1 = SELF; "WAIT"; "("; d = INT; ")"; p2 = SELF -> Wait(p1,d,p2)] | [ x = UIDENT -> Proc(x)] ]; 

But unfortunately, the parser does not parse strings such as

 .act abort WAIT(4) :act close 

because the rule for the WAIT construct expects proc to be the first argument.

How can i fix this?

+7
parsing ocaml camlp4
source share

No one has answered this question yet.

See related questions:

362
Best XML Parser for Java
258
lexers vs parsers
thirteen
Is a good parser okamla?
8
What is the "revised syntax" in OCaml?
8
Grammar analysis using OCaml
4
Parsing an OCaml File with OCaml
one
Can I do something to avoid having to backtrack in this grammar?
0
Bison: distinguish variables by type / YYERROR in GLR parsers
0
Ocaml Lexer / Parser Rules

All Articles