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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -