Package org.mozilla.javascript
Class Parser
- java.lang.Object
- 
- org.mozilla.javascript.Parser
 
- 
 public class Parser extends java.lang.ObjectThis class implements the JavaScript parser.It is based on the SpiderMonkey C source files jsparse.c and jsparse.h in the jsref package. The parser generates an AstRootparse tree representing the source code. No tree rewriting is permitted at this stage, so that the parse tree is a faithful representation of the source for frontend processing tools and IDEs.This parser implementation is not intended to be reused after a parse finishes, and will throw an IllegalStateException() if invoked again. - See Also:
- TokenStream
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description protected classParser.PerFunctionVariables
 - 
Field SummaryFields Modifier and Type Field Description static intARGC_LIMITMaximum number of allowed function or constructor arguments, to follow SpiderMonkey.protected booleaninUseStrictDirectiveprotected intnestingOfFunction
 - 
Constructor SummaryConstructors Constructor Description Parser()Parser(CompilerEnvirons compilerEnv)Parser(CompilerEnvirons compilerEnv, ErrorReporter errorReporter)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidcheckActivationName(java.lang.String name, int token)protected voidcheckMutableReference(Node n)protected NodecreateName(int type, java.lang.String name, Node child)protected NodecreateName(java.lang.String name)protected NodecreateNumber(double number)protected ScopecreateScopeNode(int token, int lineno)Create a node that can be used to hold lexically scoped variable definitions (via let declarations).booleaneof()booleaninUseStrictDirective()AstRootparse(java.io.Reader sourceReader, java.lang.String sourceURI, int lineno)Deprecated.use parse(String, String, int) insteadAstRootparse(java.lang.String sourceString, java.lang.String sourceURI, int lineno)Builds a parse tree from the given source string.protected AstNoderemoveParens(AstNode node)voidsetDefaultUseStrictDirective(boolean useStrict)protected voidsetIsGenerator()protected voidsetRequiresActivation()protected NodesimpleAssignment(Node left, Node right)
 
- 
- 
- 
Field Detail- 
ARGC_LIMITpublic static final int ARGC_LIMIT Maximum number of allowed function or constructor arguments, to follow SpiderMonkey.- See Also:
- Constant Field Values
 
 - 
nestingOfFunctionprotected int nestingOfFunction 
 - 
inUseStrictDirectiveprotected boolean inUseStrictDirective 
 
- 
 - 
Constructor Detail- 
Parserpublic Parser() 
 - 
Parserpublic Parser(CompilerEnvirons compilerEnv) 
 - 
Parserpublic Parser(CompilerEnvirons compilerEnv, ErrorReporter errorReporter) 
 
- 
 - 
Method Detail- 
eofpublic boolean eof() 
 - 
parsepublic AstRoot parse(java.lang.String sourceString, java.lang.String sourceURI, int lineno) Builds a parse tree from the given source string.- Returns:
- an AstRootobject representing the parsed program. If the parse fails,nullwill be returned. (The parse failure will result in a call to theErrorReporterfromCompilerEnvirons.)
 
 - 
parse@Deprecated public AstRoot parse(java.io.Reader sourceReader, java.lang.String sourceURI, int lineno) throws java.io.IOException Deprecated.use parse(String, String, int) insteadBuilds a parse tree from the given sourcereader.- Throws:
- java.io.IOException- if the- Readerencounters an error
- See Also:
- parse(String,String,int)
 
 - 
checkActivationNameprotected void checkActivationName(java.lang.String name, int token)
 - 
setRequiresActivationprotected void setRequiresActivation() 
 - 
setIsGeneratorprotected void setIsGenerator() 
 - 
createNameprotected Node createName(java.lang.String name) 
 - 
createNumberprotected Node createNumber(double number) 
 - 
createScopeNodeprotected Scope createScopeNode(int token, int lineno) Create a node that can be used to hold lexically scoped variable definitions (via let declarations).- Parameters:
- token- the token of the node to create
- lineno- line number of source
- Returns:
- the created node
 
 - 
checkMutableReferenceprotected void checkMutableReference(Node n) 
 - 
setDefaultUseStrictDirectivepublic void setDefaultUseStrictDirective(boolean useStrict) 
 - 
inUseStrictDirectivepublic boolean inUseStrictDirective() 
 
- 
 
-