The Project

Chapter 11. Glossary

Table of Contents

Glossary

This section describes some of the terms used in the sid documentation.

Glossary

Alternative

An alternative is a sequence of items.

Exception handler

An exception handler is a special type of alternative. Each rule may have at most one exception handler. An exception handler is invoked if the current terminal does not match any of the expected terminals, if a predicate fails, or if an action raises an exception, within the scope of the exception handler.

Expansion

This is the process of physically inlining a rule into another rule. It is done during the factoring process to turn the grammar into a form that a parser can be produced for. See the entry for factoring.

Factoring

This is one of the transforms that sid performs on the grammar. See the overview section for a description of the factoring process.

First set

The first set of a rule (or alternative) is the set of terminals and predicates that can start that rule (or alternative).

Follow set

The follow set of a rule is the set of terminals and predicates that can follow the rule in any of its invocations.

Inlining

This is the process of outputting the code for parsing one rule within the function that parses another rule. This is normally done as part of the output process. Expansion is a form of inlining performed during the factoring process, but the inlining is done by modifying the grammar, rather than as part of the output phase.

Item

An item is the equivalent of a statement in a conventional programming language. It can be an invocation of a rule, terminal, action or predicate, or an identity operation (assignment).

Name

A name is an identifier that is used to pass information between rules and actions. Local names are defined within a rule, and only exist within the rule itself. Non-local names are defined in a rule's scoped definitions section and exists in all of the rules in that scope. Non-local rules are also saved and restored across calls to the rule that defines them.

Recursion

Recursion is where a rule invokes itself. Direct recursion is where the rule invokes itself from one of its own alternatives; indirect recursion is where a rule invokes another rule (which invokes another rule etc.) which eventually invokes the original rule.

Left recursion is a form of recursion where all of the recursive calls occur as the first item in an alternative. It is not possible to produce a parser for a grammar that contains left recursions, so sid turns left recursions into right recursions. This process is known as left recursion elimination.

Right recursion is a form of recursion where all of the recursive calls occur as the last item in an alternative.

Production

See rule.

Rule

A rule is a sequence of alternatives. A rule may contain a special alternative that is used as an exception handler. A rule is also referred to as a production; this term is normally used when talking about the definition of a rule.

See-through

A rule is said to be see-through if there is an expansion of the rule that does not contain any terminals or predicates.