Grammatica Reference Manual
Terms & Definitions
Grammatica uses a specific terminology that is important to
understand. Those same terms are also used in this reference
manual and in other documents. The list below attempts to define
and describe the most important of these terms.
-
Grammar
A definition of a language. Grammatica only supports
artifical languages that are context-free, i.e. grammars
where all ambiguities can be resolved without requiring
full knowledge of the context. A grammar is defined by a set
of tokens and productions.
-
Token
A group of one or more characters belonging together. A
token is similar to a word in a natural language, and is the
fundamental building block in the grammar. A token is normally
defined in the form of a string or a regular expression.
-
Regular Expression
A language for matching character sequences. The regular
expression syntax varies slightly between implementations, but
a good definition is available in Java API for the java.util.regexp.Pattern
class. Regular expressions are used to define tokens in
the grammar.
-
Production
A grammar rule defining a token sequence. The productions
are described in EBNF, and contain a number of references to
tokens and other productions. A production may have several
mutually exclusive production alternatives.
-
Production Alternative
A sequence of token or production references. Each
production contains at least one production alternative, but
may have several. Each production alternative is mutually
exclusive and at most one may match a specific token
sequence.
-
EBNF (Extended Backus-Naur Form)
A syntax for defining productions. The EBNF syntax varies
slightly between implementations, but a good definition is
available here.
EBNF is used to define productions in the grammar.
-
Parse
The process of reading and analyzing a character stream.
A parser is a program that can read input characters and
structure them according to a grammar.
-
Parse Tree
A tree data structure formed during the parsing. Each
token and production matched is present in the tree, in the
hierarchical order in which they were processed.
-
Syntax Tree
Similar to a parse tree. Often the term abstract syntax
tree (AST) is used as a synonym to parse tree, although an
abstract syntax tree may possibly have been modified after the
parsing.