Specifying dynamic priority and operator priority in Menhir / Ocamlyacc

I am trying to parse a language where operators have dynamic attributes (priority and priority) using the Menhir parser (similar to Ocamlyacc). During the vocabulary phase, all operators fill in the token OP:string(therefore, β€œ+” turns into (OP "+"), etc.).

Operator attributes are defined during parsing and populate the tables linking the operators and their attributes. Given this table, how can I tell Menhir to dynamically change the priority of a rule that analyzes statements based on this table data?

Thanks CharlieP.

+5
source share
1 answer

" ". , , , :

  • Menhir ; , , , ​​ GLR Dypgen. Dypgen (, , ), . . 6.6 Dypgen (PDF), ... 42.

  • CFG - , , . Agda mixfix, : CFG , , , , , , . , let x = if foo then x + y * z else bar - Let(x, If(foo, Expr(x, +, y, *, z), bar). Expr . , ( CFG), , , . Agda , Parsing Mixfix Operators, Danielsson Norell, 2009.

    , , , , , .

  • , , . OCaml , (, @, @@ @+ -). , , , , , , . , , (, camlp4 <:foo< ... >>) , , .

    , , , , . , , , .

+10

All Articles