Macaulay2 » Documentation
Packages » Parsing :: Parsing
next | previous | forward | backward | up | index | toc

Parsing -- a framework for building parsers

Description

Parsing is a package the provides a framework for building parsers. It introduces Parser, a type of function that parses a sequence of tokens, and Analyzer, a type of function that accepts input for the parser in its original form and separates it into a stream of tokens. A parser can be combined with an analyzer: see Parser : Analyzer, to produce a complete system for accepting input and parsing it.

See the package Classic for a good example of the use of this framework.

Author

Version

This documentation describes version 1.0 of Parsing.

Source code

The source code from which this documentation is derived is in the file Parsing.m2.

Exports

  • Types
    • Analyzer -- the class of all lexical analyzers
    • Parser -- the class of all parsers
  • Functions and commands
    • andP -- parser conjunction
    • charAnalyzer -- a lexical analyzer that provides characters from a string one at a time
    • constParser -- produce a parser that accepts a fixed string, one character at a time
    • deadParser -- a parser which accepts no tokens and is not in a terminal state
    • futureParser -- forward reference to a parser not defined yet
    • letterParser -- a parser that accepts a single letter and returns it
    • NNParser -- a parser that accepts (and returns) a natural number, one character at a time
    • nonspaceAnalyzer -- a lexical analyzer that provides non-white-space characters from a string one at a time
    • nullParser -- a terminal parser that returns the value nil
    • optionalSignParser -- a parser that accepts an optional plus sign or minus sign
    • optP -- making a parser optional
    • orP -- parsing alternatives
    • QQParser -- a parser that accepts (and returns) a rational number, one character at a time
    • terminalParser -- produce a parser in a terminal state
    • ZZParser -- a parser that accepts (and returns) an integer, one character at a time
  • Methods
    • * Parser -- repetition of a parser
    • + Parser -- repetition of a parser at least once
    • Parser @ Parser -- see andP -- parser conjunction
    • Parser @ String -- see andP -- parser conjunction
    • String @ Parser -- see andP -- parser conjunction
    • Function % Parser -- transform the value returned by a parser
    • Parser | Parser -- see orP -- parsing alternatives
    • Parser | String -- see orP -- parsing alternatives
    • String | Parser -- see orP -- parsing alternatives
    • Parser : Analyzer -- combine a parser with a lexical analyzer to make a complete system
  • Symbols
    • nil -- a symbol a parser may return to indicate acceptance of the empty string of tokens

For the programmer

The object Parsing is a package.

Menu