com.google.javascript.rhino
Class Parser
java.lang.Object
com.google.javascript.rhino.Parser
public class Parser
- extends Object
This class implements the JavaScript parser.
It is based on the C source files jsparse.c and jsparse.h
in the jsref package.
- See Also:
TokenStream
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Parser
public Parser(CompilerEnvirons compilerEnv,
ErrorReporter errorReporter)
parse
public static ScriptOrFnNode parse(String sourceString,
String sourceURI)
- Parses JavaScript source in a new
Context
with the default
CompilerEnvirons
. Ignores parse warnings.
- Parameters:
sourceString
- JavaScript source codesourceURI
- the source code URI or file name
- Returns:
- a
Node
representing the parsed program (never null)
- Throws:
RhinoException
- if there are any errors during the parse
parseWithJSDoc
public static ScriptOrFnNode parseWithJSDoc(String sourceString,
String sourceURI)
- Parses JavaScript source plus JSDoc annotations in a new
Context
.
Ignores parse warnings. Use parse(String,String)
to ignore
JSDoc.
- Parameters:
sourceString
- JavaScript source codesourceURI
- the source code URI or file name
- Returns:
- a
Node
representing the parsed program (never null)
- Throws:
RhinoException
- if there are any errors during the parse
initForUnitTest
public TokenStream initForUnitTest(Reader sourceReader,
String sourceURI,
int lineno,
boolean parseJSDoc)
parse
public ScriptOrFnNode parse(String sourceString,
String sourceURI,
int lineno)
parse
public ScriptOrFnNode parse(Reader sourceReader,
String sourceURI,
int lineno)
throws IOException
- Throws:
IOException