Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Dynamic Languages Toolkit (DLTK) » DLTKCore and the AST of expressions and statements(Going deeper than methods for Python and Ruby)
DLTKCore and the AST of expressions and statements [message #1113191] Fri, 20 September 2013 19:42 Go to next message
Alexandre Torres is currently offline Alexandre TorresFriend
Messages: 139
Registered: July 2009
Senior Member
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 Go to previous messageGo to next message
Rodrigo Antonio is currently offline Rodrigo AntonioFriend
Messages: 17
Registered: June 2010
Location: São Paulo - Brasil
Junior Member
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
Re: DLTKCore and the AST of expressions and statements [message #1220987 is a reply to message #1220637] Mon, 16 December 2013 14:04 Go to previous messageGo to next message
Alexandre Torres is currently offline Alexandre TorresFriend
Messages: 139
Registered: July 2009
Senior Member
No Message Body
Re: DLTKCore and the AST of expressions and statements [message #1220988 is a reply to message #1220987] Mon, 16 December 2013 14:08 Go to previous message
Alexandre Torres is currently offline Alexandre TorresFriend
Messages: 139
Registered: July 2009
Senior Member
yes, but I would have to write everything from zero.
Nevertheless I found out, I just had to use PythonSourceParser and parse the IModuleSource Smile
It is much more easier to work with an AST than ANTLR.
Previous Topic:DLTK and PHP project
Next Topic:Unparsing Ruby/Python/Whatever
Goto Forum:
  


Current Time: Wed Dec 11 16:00:18 GMT 2024

Powered by FUDForum. Page generated in 0.03168 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top