Syntactic & semantic phases

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Syntactic & semantic phases

Gavin
This is a follow up to this thread. In that thread, the discussion was about the phases of lexing and syntax.

I just want to know if one should build a parse tree; then run a different semantic phase over the parse tree. Or is it ok to be running the semantic phase over the tree as it is built ?

e.g. When parsing mathematical expressions; should I be evaluating the result or wait for the final parse tree to complete.

Regards,

Gavin

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Syntactic & semantic phases

mathias
Administrator
Hi Gavin,

in most application it doesn't really make sense to build a parse tree.
Instead most application build an Abstract Syntax Tree, that represents the input at a higher level of abstraction and using application specific tree nodes.
"Uninteresting" things like whitespace, braces, etc. would not be represented in the AST (but they are in the parse tree).

In a second phase the application then works with the AST to do whatever it needs to do. In your case it would likely be evaluating the mathematical expressions...

HTH...

Cheers,
Mathias

---
[hidden email]
http://www.parboiled.org

On 29.04.2011, at 13:18, Gavin[via parboiled users] wrote:

> This is a follow up to this thread. In that thread, the discussion was about the phases of lexing and syntax.
>
> I just want to know if one should build a parse tree; then run a different semantic phase over the parse tree. Or is it ok to be running the semantic phase over the tree as it is built ?
>
> e.g. When parsing mathematical expressions; should I be evaluating the result or wait for the final parse tree to complete.
>
> Regards,
>
> Gavin
>
>
>
> If you reply to this email, your message will be added to the discussion below:
> http://users.parboiled.org/Syntactic-semantic-phases-tp2878802p2878802.html
> To start a new topic under parboiled users, email [hidden email]
> To unsubscribe from parboiled users, click here.

Loading...