Package org.mozilla.javascript
Class Parser
java.lang.Object
org.mozilla.javascript.Parser
- Direct Known Subclasses:
IRFactory
This 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 AstRoot
parse 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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Maximum number of allowed function or constructor arguments, to follow SpiderMonkey. -
Constructor Summary
ConstructorsConstructorDescriptionParser()
Parser
(CompilerEnvirons compilerEnv) Parser
(CompilerEnvirons compilerEnv, ErrorReporter errorReporter) -
Method Summary
-
Field Details
-
ARGC_LIMIT
public static final int ARGC_LIMITMaximum number of allowed function or constructor arguments, to follow SpiderMonkey.- See Also:
-
-
Constructor Details
-
Parser
public Parser() -
Parser
-
Parser
-
-
Method Details
-
eof
public boolean eof() -
parse
Builds a parse tree from the given source string.- Returns:
- an
AstRoot
object representing the parsed program. If the parse fails,null
will be returned. (The parse failure will result in a call to theErrorReporter
fromCompilerEnvirons
.)
-
parse
Builds a parse tree from the given sourcereader.- Throws:
IOException
- if theReader
encounters an error- See Also:
-