Documentation ¶
Overview ¶
Package generator implements a parser generator.
Package generator generates a parser which provides the function pgParse:
// pgParse returns an AST node. func pgParse() pgNode
pgParse returns an AST node. The returned node is of the type of the start production of the grammar. If no production could be applied, a node with type "error" is returned.
An node looks like this:
// pgNode is an element in the abstract syntax tree. type pgNode struct { typ string // type, as defined in the grammar or "error" val string // actual value or empty for non-terminal nodes children []pgNode // child nodes, empty for terminal nodes }
pgParse uses pgLex to obtain the next lexical token. The client package must implement a function pgLex:
// pgLex is called to obtain the next // lexical token tok of type typ. pgLex // returns "$" to indicate end of input. pgLex() (typ, tok string)
The client package must also implement a function pgError, which is called if an error occurs while parsing.
// pgError is called if an error // occurred while parsing. pgError(err error)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.