c++ - BOOST SPIRIT parsing - create correct AST tree -


i have parse using boost spirit sequence like

t1 join t2 join t3 join ... join tn 

and result should ast tree semantics

((...((t1 join t2) join t3) join ...) join tn) 

i tried use rule like:

source = singletable | (source >> join >> singletable); 

but, per boost spirit design, parsing process uses first part of rule , parses first item ("t1") expression , lefts rest of sequence not parsed ("join t2 join t3 join ... join tn").

which best way solve problem?

i can rewrite rule like

source = (singletable >> join >> source) | singletable; 

but in case created ast

(t1 join (t2 join (t3 join (... join tn)...))). 

so need supplementary processing step ast desired form.

is there other method provides correct ast after parsing?

*aside database engines don't blindly create asts that. more likely, create unordered list of row sources ((joins to) tables/views) , let query optimizer work out how optimally plan execution.

barring better example of actual ast, here's rule comes closer:

 singletable >> - ("join" >> source) 

Comments

Popular posts from this blog

symfony - TEST environment only: The database schema is not in sync with the current mapping file -

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -