ASC Parser: are there ranges (not just positions)?


#1

I’m so far still interested in a AS3 parser that parses a single AS3 source and results in an AST. The bestly-implemented so far looks to be the FlexSDK ASC parser, which zwetan linked in my earlier thread.

But since this parser itself isn’t nicely documented, I’ve pre-mature (didn’t use it yet…), but important questions:

  • How does it store line info about AST Nodes? E.g., start (index, lineNumber & lineIndex) & end (index, lineNumber & lineIndex), in a way I’m able to know at least the starting or ending column of a single Node?

All I see is the method Node#pos() in Node.java, but it’s not very specific for me (starting or ending pos? And if pos() returns column, then what about lines?).

I need these.


#2

search for PrettyPrinter, PrintWriter and NodePrinter etc.

you will pass the AST to an evalutator type of class (also known as visitor)
so it can output via a printer

look into the swfutils source too


#3

I see EvaluatorAdaptor is fundamental, but it should be possible to get at least the line number of a node. E.g.:

// WithStatementNode
with(displayObj) x;
// with is on 2:0 (line 2, column 1)

Programatically I don’t have min idea in asc.parser.Parser… Node.java has no line thing… X_X

I did read the classes you said, but I didn’t find anything. But there should be a way to handle lines, as mxmlc is able to get line numbers and etc., right?