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

Analyzer -- the class of all lexical analyzers

Description

A function that accepts input in its original form and separates it into tokens, will be called a lexical analyzer. These analyzers are functional: call one with the original input, and it returns a function of 0 arguments (with changeable internal state) that keeps returning tokens each time it is called until none are left. Actually, the analyzer is to return a pair: (pos,token), where pos is a string indicating the position where token was found in the input. A position will be a sort of thing which can be converted to string with toString (for printing error messages) and can be sorted.

Menu

Methods that use a lexical analyzer:

  • Parser : Analyzer -- combine a parser with a lexical analyzer to make a complete system

Protected objects of class Analyzer:

  • charAnalyzer -- a lexical analyzer that provides characters from a string one at a time
  • nonspaceAnalyzer -- a lexical analyzer that provides non-white-space characters from a string one at a time

For the programmer

The object Analyzer is a self initializing type, with ancestor classes FunctionClosure < Function < Thing.


The source of this document is in Parsing.m2:233:0.