DLTKCore and the AST of expressions and statements [message #1113191] |
Fri, 20 September 2013 19:42  |
Eclipse User |
|
|
|
Hi,
Looking for ANTLR implementations for Ruby and Python I found that DLTK uses ANTLR grammars to parse Python and Ruby. The grammars are quite complete (with statements such as IF, WHILE, expressions...). But when using the DLTKCore.create(...), the AST exposed by the tool does not decomposes the implementation, it seems that it ignores most of what the grammar can recognize.
What I need is to, sometimes, read the expressions and code blocks inside each method or field initialization. How could I do that using DLTK ?
Do I need to have the file open in the editor to get the AST?
I´m new to DLTK and pretty lost to what can I do. In fact I´m more into code generation and reverse engineering than user interfacing or building editors, perhaps DLTK is not what I need.
Thanks
What I see the Pyhton grammar, but can´t see in the AST:
compound_stmt returns [ Statement statement = null ]:
statement0 = if_stmt { statement = statement0; }
| statement1 = while_stmt{ statement = statement1; }
| statement2 = for_stmt{ statement = statement2; }
| statement3 = try_stmt{ statement = statement3; }
| statement4 = funcdef{ statement = statement4; }
| statement5 = classdef{ statement = statement5; }
| statement6 = with_stmt {statement = statement6; }
;
// If Statement
if_stmt returns [ IfStatement statement = null ]:
|
|
|
Re: DLTKCore and the AST of expressions and statements [message #1220637 is a reply to message #1113191] |
Thu, 12 December 2013 19:19   |
Eclipse User |
|
|
|
Hi,
I'm little confused.
DLTK is to you building full featured development environment. Like a new IDE for a language.
If I understand what you want to do, You need only ANTLR.
With ANTLR you can build your AST for your grammar. But you really need a AST?
If you only need emit a action when you parser your file, you can use antlr 4.0 with listener.
It's very powerful and more easy to do.
Thanks
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03778 seconds