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
ident (capitals), and delimited sequences
(semantic-fetch-tags)to get the tree. Try it in C/C++ mode or Emacs Lisp mode. Here is an example of using manipulating the tags in the function srefactor--fetch-candidates-helper of my package
srefactorto produce a navigation tree.
nilfor me, even after