Semantic Action or Parser Tree or AST tree

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Semantic Action or Parser Tree or AST tree

Yiqing

Hi,

 

I am a newbie for Spirit. I used Antlr before to create a parser for predicate expression. Now I need to create a parser for a SQL like query language, a much bigger size parser. The end result we need after parsing is an expression tree with operators and operands  to describe the query using our own expression tree library.

I have been reading Spirit docs and trying to figure out if it’s a better tool, and how to use it to implement my query language.

 

It seems to me that I can’t take advantage of the convenient features provided by Semantic Action to do this, as the children nodes will be created earlier than the parent node if the nodes creation is  executed by the semantic actions, but the expression tree has to be built from top down.

It seems that I should still use the Parser tree or AST tree to accomplish this. Before going on this path, I would like to get confirmed from experts that’s the way to go! Also, what’s the difference between using Parser tree or AST tree?

 

Thanks in advance,

 

Yiqing


------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: Semantic Action or Parser Tree or AST tree

teajay-2
Le 28/04/2015 20:16, YiQing Yang a écrit :

> Hi,
>
> I am a newbie for Spirit. I used Antlr before to create a parser for
> predicate expression. Now I need to create a parser for a SQL like query
> language, a much bigger size parser. The end result we need after
> parsing is an expression tree with operators and operands  to describe
> the query using our own expression tree library.
>
> I have been reading Spirit docs and trying to figure out if it’s a
> better tool, and how to use it to implement my query language.
>
> It seems to me that I can’t take advantage of the convenient features
> provided by Semantic Action to do this, as the children nodes will be
> created earlier than the parent node if the nodes creation is  executed
> by the semantic actions, but the expression tree has to be built from
> top down.
>
> It seems that I should still use the Parser tree or AST tree to
> accomplish this. Before going on this path, I would like to get
> confirmed from experts that’s the way to go! Also, what’s the difference
> between using Parser tree or AST tree?
>
> Thanks in advance,
>
> Yiqing
>

Hello Yiging,

Semantic actions have a certain runtime penalty and should be avoided if
possible. The best approach is to either produce a dedicated data
structure direct out of the parser (I guess that is what you call a
Parser tree), or an AST. Both should produce similar results regarding
runtime performance.

Personnaly I tend to favor parser trees in situations where the data
structures are easily produced by the parser and need no transformation
before being usable. But as mentioned earlier both approaches are similar.

Regards,

Thomas Bernard


------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: Semantic Action or Parser Tree or AST tree

Yiqing
In reply to this post by Yiqing
Thanks Thomas for your advice.  
 
It seems that Parser tree is only available in Spirit Classic. Is there parser tree api available with the Qi parser?
 
Thanks,
 
Yiqing

 


------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: Semantic Action or Parser Tree or AST tree

Richard-45

In article <[hidden email]>,
    YiQing Yang <[hidden email]> writes:

> It seems that Parser tree is only available in Spirit Classic. Is there
> parser tree api available with the Qi parser?

When I read "parser tree" on this thread, I was thinking of the
automatically synthesized attributes for parser rules that are created
by Spirit.  When I presented Boost.Spirit to the Utah C++ Programmers
group, I created two example parsers: JSON and email date/time.

You can find both those examples on github:
<https://github.com/LegalizeAdulthood/ucpp-json-parser>
<https://github.com/LegalizeAdulthood/ucpp-date-time-parser>
--
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
     The Computer Graphics Museum <http://ComputerGraphicsMuseum.org>
         The Terminals Wiki <http://terminals.classiccmp.org>
  Legalize Adulthood! (my blog) <http://LegalizeAdulthood.wordpress.com>

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: Semantic Action or Parser Tree or AST tree

Yiqing
In reply to this post by Yiqing
In article <CO2PR0801MB677BD56F0E94DCBA034BE0CDAE80@...>,
    YiQing Yang <yiqing@...> writes:
 
> It seems that Parser tree is only available in Spirit Classic. Is there
> parser tree api available with the Qi parser?
 
Richard Replied
 
> When I read "parser tree" on this thread, I was thinking of the
> automatically synthesized attributes for parser rules that are created
> by Spirit.  When I presented Boost.Spirit to the Utah C++ Programmers
> group, I created two example parsers: JSON and email date/time.
 
>You can find both those examples on github:
> <https://github.com/LegalizeAdulthood/ucpp-json-parser>;
><https://github.com/LegalizeAdulthood/ucpp-date-time-parser>;
-- 

 

Richard ,  

As a general term for "parser tree" , you are right. But here specifically I meant the utility classes provided in the classic Spirit for accessing the parser tree; such as the pt_parse

tree_parse_info<IteratorT>

defined in classic_parse_tree.hpp

 

I was wondering if there is one available to work with the Qi grammar.

 

BTW, I can’t access the examples on github, got 404 error. Could you send them to [hidden email]?  

 

Thanks,

 

Yiqing

 

 

 

 

 


------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: Semantic Action or Parser Tree or AST tree

Richard-45

In article <[hidden email]>,
    YiQing Yang <[hidden email]> writes:

> BTW, I can't access the examples on github, got 404 error. Could you send
> them to [hidden email]<mailto:[hidden email]>?

There's nothing wrong with the links, so if I send them to you again
in private email, how would that fix it?

google for "github spirit json parser" and mine show sup.
--
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
     The Computer Graphics Museum <http://ComputerGraphicsMuseum.org>
         The Terminals Wiki <http://terminals.classiccmp.org>
  Legalize Adulthood! (my blog) <http://LegalizeAdulthood.wordpress.com>

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: Semantic Action or Parser Tree or AST tree

Lars Viklund
On Wed, Apr 29, 2015 at 05:02:25PM -0600, Richard wrote:
>
> In article <[hidden email]>,
>     YiQing Yang <[hidden email]> writes:
>
> > BTW, I can't access the examples on github, got 404 error. Could you send
> > them to [hidden email]<mailto:[hidden email]>?
>
> There's nothing wrong with the links, so if I send them to you again
> in private email, how would that fix it?

In some areas of the world, parts of the world wide web are not quite as
functional as you would like them to be as an individual, for the
greater good.

I believe he desired a hardcopy of the files attached to an email.

> google for "github spirit json parser" and mine show sup.

--
Lars Viklund | [hidden email]

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: Semantic Action or Parser Tree or AST tree

Yiqing
That's OK, I can download it.
Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: Semantic Action or Parser Tree or AST tree

Yiqing
In reply to this post by Lars Viklund
That's OK, I can download it.
Thanks.