2 Lexing and Parsing
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
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.
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
Parses a single source element.
Parses a sequence of source elements.
Parses a single expression.
Skips past meaningless whitespace tokens.
Constructs a new parser% which receives tokens from lexer.
2.7 Parsing Functions
The args string represents the comma-separated formal parameter list, and the body string
represents the function body (not including the surrounding braces).