How can I construct a parse tree from a string and a simple grammar? Semantic seems very tricky, and SMIE does not seem to produce a parse tree.
Here's an example, assuming a language that looks like this:
BLAH [ FOO "aaa"; "bbb" | BAR [ "ccc" | "ddd" ] ]
How can I simply transform that string into the following sexp, or something close?
(seq (ident "BLAH")
(choice (cons (seq (ident "FOO") (str "aaa"))
(seq (str "bbb")))
(seq (ident "BAR")
(choice (seq (str "ccc")) (seq (str "ddd"))))))
(essentially there are sequences seq
(no delimiters), grouping choices choice
([]
), strings ""
, identifiers ident
(capitals), and delimited sequences cons
(;
-delimited))