|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.flagstone.translate.ASParser
public final class ASParser
The ASParser framework is a collection of classes used to implement a compiler for Macromedia's ActionScript, Version 1.0. ActionScript statements are parsed to generate the byte-codes and actions that will be executed by the Flash Player. The parser translates ActionScript into a tree of ASNode objects which are then encoded to the byte-codes and actions that will be executed by the Flash Player.
String script = "gotoFrame(1)"; byte[] encodedActions = parser.parse(script).encode(swfVersion);The version of Flash (swf) that the script is being encoded for must be passed to the root ASNode when the tree of nodes is encoded. The format of the data structures that represent clip and button events changed when version 6 and version 7 of the Flash File Format Specification was released. Search Paths
try { String script = "on(mouseDown) { startDrag(); }"; ... ASNode root = parser.parse(script); ... } catch (ParseException e) { String filename = parser.getFilename(); String line = parser.getLine(); String message = parser.getError(); int lineNumber = parser.getLineNumber(); ... }
Field Summary | |
---|---|
static java.lang.String[] |
errorKeys
Keys that identify the different types of error generated while #include directives are being processed and the script is being parsed. |
Token |
jj_nt
|
boolean |
lookingAhead
|
Token |
token
|
ASParserTokenManager |
token_source
|
Fields inherited from interface com.flagstone.translate.ASParserConstants |
---|
ADD, AND, ASR, ASSIGN, ASSIGN_ADD, ASSIGN_AND, ASSIGN_ASR, ASSIGN_DIV, ASSIGN_LSL, ASSIGN_LSR, ASSIGN_MOD, ASSIGN_MUL, ASSIGN_OR, ASSIGN_SUB, ASSIGN_XOR, BIT_AND, BIT_NOT, BIT_OR, BIT_XOR, BOOLEAN_LITERAL, BREAK, CASE, CATCH, CONTINUE, DEC, DECIMAL_LITERAL, DEFAULT, DEFAULT_CASE, DELETE, DIGIT, DIVIDE, DO, DOUBLE_QUOTE, ELSE, EOF, EQ, EXPONENT, FINALLY, FLOATING_POINT_LITERAL, FOR, FUNCTION, GT, GTE, HEX_LITERAL, IDENTIFIER, IF, IN, INC, INSTANCEOF, INTEGER_LITERAL, LETTER, LOGICAL_AND, LOGICAL_NOT, LOGICAL_OR, LSL, LSR, LT, LTE, MINUS, MOD, MULTIPLY, NE, NEW, NULL_LITERAL, ON, ONCLIPEVENT, OR, PLUS, RETURN, SINGLE_QUOTE, STRICT_EQ, STRICT_NEQ, STRING_EQ, STRING_GE, STRING_GT, STRING_LE, STRING_LITERAL, STRING_NEQ, SWITCH, THROW, tokenImage, TRY, VAR, WHILE, WITH |
Constructor Summary | |
---|---|
ASParser()
Constructs a new parser object. |
|
ASParser(ASParserTokenManager tm)
|
|
ASParser(java.io.InputStream stream)
|
|
ASParser(java.io.InputStream stream,
java.lang.String encoding)
|
|
ASParser(java.io.Reader stream)
|
Method Summary | |
---|---|
void |
add(java.lang.String path)
Add a path to the array of pathnames. |
ASNode |
AdditiveExpression()
|
ASNode |
AndExpression()
|
ASNode |
AnonymousArray()
|
ASNode |
AnonymousObject()
|
ASNode |
ArgumentList()
|
ASNode |
AssignmentExpression()
|
ASNode |
Attribute()
|
ASNode |
BlockStatement()
|
ASNode |
BreakStatement()
|
ASNode |
ConditionalExpression()
|
ASNode |
Constructor()
|
ASNode |
ContinueStatement()
|
void |
disable_tracing()
|
ASNode |
DoStatement()
|
void |
enable_tracing()
|
ASNode |
EqualityExpression()
|
ASNode |
ExclusiveOrExpression()
|
ASNode |
Expression()
|
ASNode |
ExpressionList()
|
ASNode |
ExpressionStatement()
|
ASNode |
ForStatement()
|
ASNode |
Function()
|
ASNode |
FunctionDefinition()
|
ParseException |
generateParseException()
|
java.lang.String |
getError()
Returns the key identifying the type of error that occured while of parsing a script. |
java.lang.String |
getFilename()
Returns the name of the file that contained the line of code that generated an error while parsing a script. |
java.lang.String |
getLine()
Returns the line of code that generated an error while parsing a script. |
int |
getLineNumber()
Returns the number of the the line of code that generated an error parsing a script. |
Token |
getNextToken()
|
java.util.ArrayList |
getPaths()
Returns the array of path names used when searching for a file. |
Token |
getToken(int index)
|
ASNode |
Identifier()
|
ASNode |
IfStatement()
|
ASNode |
InclusiveOrExpression()
|
ASNode |
InstanceExpression()
|
ASNode |
Literal()
|
ASNode |
LogicalAndExpression()
|
ASNode |
LogicalOrExpression()
|
ASNode |
MethodDefinition()
|
ASNode |
MultiplicativeExpression()
|
ASNode |
On()
|
ASNode |
OnClipEvent()
|
ASNode |
parse(java.io.File file)
Parses the file containing ActionScript. |
ASNode |
parse(java.lang.String script)
Parses the ActionScript string, script. |
ASNode |
PostfixExpression()
|
ASNode |
PrimaryExpression()
|
ASNode |
PrimaryPrefix()
|
ASNode |
PrimarySuffix()
|
void |
ReInit(ASParserTokenManager tm)
|
void |
ReInit(java.io.InputStream stream)
|
void |
ReInit(java.io.InputStream stream,
java.lang.String encoding)
|
void |
ReInit(java.io.Reader stream)
|
ASNode |
RelationalExpression()
|
ASNode |
ReturnStatement()
|
ASNode |
Script()
|
void |
setPaths(java.util.ArrayList paths)
Sets the array of path names used when searching for a file. |
void |
setPaths(java.lang.String paths)
Sets the array of path names used when searching for a file. |
ASNode |
ShiftExpression()
|
ASNode |
Statement()
|
ASNode |
SwitchLabel()
|
ASNode |
SwitchStatement()
|
ASNode |
ThrowStatement()
|
ASNode |
TryStatement()
|
ASNode |
UnaryExpression()
|
ASNode |
WhileStatement()
|
ASNode |
WithStatement()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static java.lang.String[] errorKeys
public ASParserTokenManager token_source
public Token token
public Token jj_nt
public boolean lookingAhead
Constructor Detail |
---|
public ASParser()
public ASParser(java.io.InputStream stream)
public ASParser(java.io.InputStream stream, java.lang.String encoding)
public ASParser(java.io.Reader stream)
public ASParser(ASParserTokenManager tm)
Method Detail |
---|
public java.util.ArrayList getPaths()
public void setPaths(java.util.ArrayList paths)
paths
- an array of strings containing the names of directories to search.public void setPaths(java.lang.String paths)
paths
- a string containing the names of directories to search.public void add(java.lang.String path)
path
- a string containing the path to a directory.public java.lang.String getFilename()
public int getLineNumber()
public java.lang.String getLine()
public java.lang.String getError()
public ASNode parse(java.lang.String script) throws ParseException
script
- a String containing the ActionScript code to parse.
ParseException
- if a parsing error occurs.public ASNode parse(java.io.File file) throws ParseException
file
- a File containing the ActionScript statements to parse.
ParseException
- if a parsing error occurs.public final ASNode Literal() throws ParseException
ParseException
public final ASNode Identifier() throws ParseException
ParseException
public final ASNode Script() throws ParseException
ParseException
public final ASNode Statement() throws ParseException
ParseException
public final ASNode FunctionDefinition() throws ParseException
ParseException
public final ASNode BlockStatement() throws ParseException
ParseException
public final ASNode ExpressionStatement() throws ParseException
ParseException
public final ASNode IfStatement() throws ParseException
ParseException
public final ASNode WithStatement() throws ParseException
ParseException
public final ASNode WhileStatement() throws ParseException
ParseException
public final ASNode DoStatement() throws ParseException
ParseException
public final ASNode ForStatement() throws ParseException
ParseException
public final ASNode BreakStatement() throws ParseException
ParseException
public final ASNode ContinueStatement() throws ParseException
ParseException
public final ASNode ReturnStatement() throws ParseException
ParseException
public final ASNode OnClipEvent() throws ParseException
ParseException
public final ASNode On() throws ParseException
ParseException
public final ASNode TryStatement() throws ParseException
ParseException
public final ASNode ThrowStatement() throws ParseException
ParseException
public final ASNode SwitchStatement() throws ParseException
ParseException
public final ASNode SwitchLabel() throws ParseException
ParseException
public final ASNode ExpressionList() throws ParseException
ParseException
public final ASNode ArgumentList() throws ParseException
ParseException
public final ASNode Expression() throws ParseException
ParseException
public final ASNode AssignmentExpression() throws ParseException
ParseException
public final ASNode ConditionalExpression() throws ParseException
ParseException
public final ASNode LogicalOrExpression() throws ParseException
ParseException
public final ASNode LogicalAndExpression() throws ParseException
ParseException
public final ASNode InclusiveOrExpression() throws ParseException
ParseException
public final ASNode ExclusiveOrExpression() throws ParseException
ParseException
public final ASNode AndExpression() throws ParseException
ParseException
public final ASNode EqualityExpression() throws ParseException
ParseException
public final ASNode RelationalExpression() throws ParseException
ParseException
public final ASNode InstanceExpression() throws ParseException
ParseException
public final ASNode ShiftExpression() throws ParseException
ParseException
public final ASNode AdditiveExpression() throws ParseException
ParseException
public final ASNode MultiplicativeExpression() throws ParseException
ParseException
public final ASNode UnaryExpression() throws ParseException
ParseException
public final ASNode PostfixExpression() throws ParseException
ParseException
public final ASNode PrimaryExpression() throws ParseException
ParseException
public final ASNode PrimaryPrefix() throws ParseException
ParseException
public final ASNode PrimarySuffix() throws ParseException
ParseException
public final ASNode Function() throws ParseException
ParseException
public final ASNode Constructor() throws ParseException
ParseException
public final ASNode AnonymousArray() throws ParseException
ParseException
public final ASNode MethodDefinition() throws ParseException
ParseException
public final ASNode AnonymousObject() throws ParseException
ParseException
public final ASNode Attribute() throws ParseException
ParseException
public void ReInit(java.io.InputStream stream)
public void ReInit(java.io.InputStream stream, java.lang.String encoding)
public void ReInit(java.io.Reader stream)
public void ReInit(ASParserTokenManager tm)
public final Token getNextToken()
public final Token getToken(int index)
public ParseException generateParseException()
public final void enable_tracing()
public final void disable_tracing()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |