Parser

class Parser(compilerEnv: CompilerEnvirons = CompilerEnvirons(), errorReporter: ErrorReporter = compilerEnv.errorReporter)

The JavaScript parser, based on the SpiderMonkey sources jsparse.c and jsparse.h.

It produces an AstRoot parse tree that mirrors the source exactly: no tree rewriting happens here, so the tree stays useful for IDEs and pretty-printers.

A Parser is single use. Calling parse twice throws.

Not ported: the Reader-based source path (D-2) and the E4X methods, so defaultXmlNamespace, xmlInitializer, attributeAccess and the XML branches of propertyName and memberExprTail report "XML not available" instead of parsing E4X syntax.

Constructors

Link copied to clipboard
constructor(compilerEnv: CompilerEnvirons = CompilerEnvirons(), errorReporter: ErrorReporter = compilerEnv.errorReporter)

Types

Link copied to clipboard
object Companion
Link copied to clipboard

Where the parser is right now, for an error message that wants to point at it.

Link copied to clipboard

Exception used to unwind out of a failed parse.

Properties

Link copied to clipboard

Functions

Link copied to clipboard
fun eof(): Boolean
Link copied to clipboard
Link copied to clipboard
fun parse(sourceString: String, sourceURI: String?, lineno: Int): AstRoot

Builds a parse tree from sourceString.

Link copied to clipboard
fun reportErrorsIfExists(baseLineno: Int)