>So would it be better to have an example like the Pie language use a
>tree grammar or is the hand-written visitor code a better approach? What
>are the pros and cons? Any help appreciated.

A pure interpreter would read statements one by one and execute them directly.
A compiler would read the whole source in one chunk and translate it before 
execution.
You can take any approach inbetween as well.

That said, I believe parsing the whole file and translating into an AST is not 
really interpretation.
But there is still the approach to parse statement for statement, and here I 
would definitely separate the grammar from execution code through an AST.

file: statement+ EOF;
statement: .....

My interpreter would open the file, construct parser and lexers, manage 
variables and scope, repeatedly ask the parser to return the AST for the next 
statement and send it for execution.
This way you would get the typical behaviour that syntax errors or else are 
detected during execution time. And if you were to change your mind towards a 
compiler, the grammar and AST construction would not change as you simply call 
the file method on the parser.

Of course it is more intersting if your interpreted language allows 
methods/procedures/functions as then parsing the source file would not be 
linear.

Hiran
___________________________________________________________
Neu: WEB.DE De-Mail - Einfach wie E-Mail, sicher wie ein Brief!  
Jetzt De-Mail-Adresse reservieren: https://produkte.web.de/go/demail02

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-inter...@googlegroups.com.
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to