[e-lang] AST view of E program
Kevin Reid
kpreid at mac.com
Mon Sep 29 15:59:55 CDT 2008
On Sep 29, 2008, at 7:49, Marcelo D. Ré wrote:
> I am working in a module to support E in NetBeans. Currently it
> sopport code highlight, braces completion, run e from the ide, and are
> developping the syntax check.
> The question is: how to grab an AST from an E file? is it posible?
def makeEParser := <import:org.erights.e.elang.syntax.makeEParser>
makeEParser.run(theFile.getTwine())
The result of this is an AST of type ENode.
All of this can be accessed from Java too.
There is one caveat: in E-on-Java, there is no reified AST for un-
expanded E syntax, only for Kernel-E. This may be sufficient,
particularly as, provided that the source is a Twine (not a String),
every ENode carries the line and column number of the source text
corresponding to it (getOptSpan).
If it isn't, you can supply your own EBuilder (or is it ENodeBuilder?
One's a class and the other's an interface) to EParser and get
messages corresponding to the full syntax.
Another option is to use the grammar from E-on-CL, which is actually
written in Java (generated by ANTLR), which provides an unexpanded AST.
> I have problem parsing the line
>
> match [] { println(uri) }
>
> in the counter-example.e.
>
> I don't find a clause that parse the "println" statement.
This is an ordinary function call. The Kernel-E AST for this is
EMatcher
ListPattern
(no children)
CallExpr
NounExpr
"println"
"run"
NounExpr
"uri"
The unexpanded AST for this in E-on-CL is
EMatcher
ListPattern
(no children)
FunCallExpr
NounExpr
"println"
NounExpr
"uri"
--
Kevin Reid <http://homepage.mac.com/kpreid/>
More information about the e-lang
mailing list