com.google.javascript.rhino
Class Parser

java.lang.Object
  extended by 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

Constructor Summary
Parser(CompilerEnvirons compilerEnv, ErrorReporter errorReporter)
           
 
Method Summary
 TokenStream initForUnitTest(Reader sourceReader, String sourceURI, int lineno, boolean parseJSDoc)
           
 ScriptOrFnNode parse(Reader sourceReader, String sourceURI, int lineno)
           
static ScriptOrFnNode parse(String sourceString, String sourceURI)
          Parses JavaScript source in a new Context with the default CompilerEnvirons.
 ScriptOrFnNode parse(String sourceString, String sourceURI, int lineno)
           
static ScriptOrFnNode parseWithJSDoc(String sourceString, String sourceURI)
          Parses JavaScript source plus JSDoc annotations in a new Context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Parser

public Parser(CompilerEnvirons compilerEnv,
              ErrorReporter errorReporter)
Method Detail

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 code
sourceURI - 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 code
sourceURI - 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