Quantcast
Channel: Active questions tagged ocaml - Stack Overflow
Viewing all articles
Browse latest Browse all 594

How to push (which is not related to any symbol) a synthetic token in Menhir Incremental?

$
0
0

I am parsing the Elm lang-like syntax. And look at the pattern matching (inside pattern matching)

case a of 1 -> case b of"hello" -> 'h'  _ -> 'w' _ -> 'e'

We see there is a significant identification case. I catch conflicts because I can't express the significant identification inside ENF. Because it isn't a context-free case.But I am creating the "synthetic token" to satisfy Menhir, and I want to push the token not inside lexer or parser files but inside the OCaml code and implicitly (for .mly and mll) push this token.Without the terminal token, I catch conflicts.

And this synthetic token is DEDENT:

| CASE expr=exprs_top OF NEWLINE   items=separated_nonempty_list(NEWLINE, expr_case) DEDENT        { Case_of({ expr; items })}

I need an example of implementing the pushing of the synthetic token inside the on_fail function.

and loop lexbuf result =  let supplier = I.lexer_lexbuf_to_supplier get_token lexbuf in  I.loop_handle_undo succeed on_fail supplier result

And also,is it even a good idea to do this (to have a synthetic token that isn't related to a symbol)?


Viewing all articles
Browse latest Browse all 594

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>