Version: 4.1.5.3
2 Lexing and Parsing
This library provides facilities for lexing and parsing JavaScript source. It can be
required via:
2.1 Input Sources
An input-source is either a string, a path, or an input port.
Determines whether x is an input-source.
Produces an input port for reading from in.
2.2 Source Representation
Re-exported from the PLT Scheme collection parser-tools/lex.
Represents a region of text from start (inclusive) to end (exclusive).
The source to a regular expression token, with regular expression pattern pattern and
flags global?, representing the /g option, and case-insensitive?,
representing the /i option.
A single token of input.
Produces a string representation of a region, convenient for debugging and error reporting.
2.3 Syntax Errors
2.4 Lexer Objects
A JavaScript lexical scanner.
Raises an exn:fail:syntax exception with error message (format fmt arg ...).
Raises an exn:fail:syntax exception with source location loc and error message (format fmt arg ...).
Determines whether the end of input has been reached.
Produces the current token in the lexer’s input stream.
Attempts to read a token of type type, producing the token on success and #f on failure.
Attempts to read a token of type type, produce the token on success and raising an exn:fail:syntax exception on failure.
Produces the next token (after skipping skip tokens) in the input stream without changing the current position in the input stream.
Similar to peek-token, but assumes the lexer is being used in a parsing state that expects an infix operator.
Similar to peek-token, but does not lex past end-of-line sequences.
Produces the next token (after skipping skip tokens) in the input stream and updates the current position in the input stream.
Similar to read-token, but does not lex past end-of-line sequences.
Rewinds the current position in the input stream by one token.
Skips past any whitespace in the underlying input port.
An implementation of lexer<%>, a JavaScript lexical scanner.
Constructs a new lexer% which reads tokens from port.
The optional name argument is used for source location information and error reporting.
2.5 Lexing Functions
Convenience function for producing a functional lexer from an input source.
2.6 Parser Objects
A JavaScript parser.
Parses a single source element.
Parses a sequence of source elements.
Parses a single expression.
Skips past meaningless whitespace tokens.
An implementation of parser<%>, a JavaScript parser.
Constructs a new parser% which receives tokens from lexer.
Produces a JavaScript parser for the input from in.
2.7 Parsing Functions
Parses a JavaScript program unit from in.
Parses a JavaScript expression from in.
Uses the arguments constructed from the JavaScript Function constructor to parse a function expression.
The args string represents the comma-separated formal parameter list, and the body string
represents the function body (not including the surrounding braces).
Parses a JavaScript source element from in.