Note: This package is provided for historical reasons. The code was previously part of the Racket distribution but was removed for lack of a maintainer. We recommend using either parser-tools/yacc or other combinator libraries such as Parsack.
This documentation provides directions on using the combinator parser library. It assumes familiarity with lexing and with combinator parsers. The library was originally developed by Kathy Gray.
This library provides a unit implementing four higher-order functions that can be used to build a combinator parser, and the export and import signatures related to it. The functions contained in this unit automatically build error reporting mechanisms in the event that no parse is found. Unlike other combinator parsers, this system assumes that the input is already lexed into tokens using parser-tools/lex. This library relies on lazy.
combinator-parser^ : signature
This signature references functions to build combinators, a function to build a runable parser using a combinator, a structure for recording errors and macro definitions to specify combinators with:
predicate : (-> token? boolean?) result : (-> token? beta) name : string? spell-check : (or/c #f (-> token? boolean?)) = #f case-check : (or/c #f (-> token? boolean?)) = #f type-check : (or/c #f (-> token? boolean?)) = #fThe returned function accepts one terminal from a token stream, and returns produces an opaque value that interacts with other combinators.The returned function accepts a term made up of a sequence of smaller terms, and produces an opaque value that interacts with other combinators.
The sequence argument is the subterms. The result argument will create the AST node for this sequence. The input list matches the length of the sequence list.
The name argument is the human-language name for this term.The returned function selects between different terms, and produces an opaque value that interacts with other combinators
The argument options is the list of the possible terms. The argument name is the human-language name for this termThe returned function accepts 0 or more instances of term, and produces an opaque value that interacts with other combinatorsReturns a function that parses a list of tokens, producing either the result of calling all appropriate result functions or an err
The location argument is either the string representing the file name or the editor being read, typically retrieved from file-path
The src field contains the source location for the error and is suitable for calling raise-read-error.
simple-spec = id | (id string) | (id proc) | (id string proc)
The name identifier specifies a group of tokens.
The ids specify tokens or terminals with no value. If provided, proc should be a procedure from tokens to AST nodes. By default, the identity function is used. The token will be a symbol. If provided, string is the human-language name for the terminal, name is used by default
If provided, proc should be a procedure from tokens to AST node. The token will be the token defined as name and will be a value token.
If name is of the form (^ id), it identifies a parser production that can be used to identify this production in an error message. Otherwise the same as above
error-format-parameters^ : signature
This signature requires five names:
language-format-parameters^ : signature
This signature requires two names:
language-dictionary^ : signature
This signature requires three names: