Marpa::R2::Semantics::Phases - Details of parse evaluation
Most users will not need to read this document. Most applications will find that the order in which Marpa executes its semantics "just works". This document describes that order in detail. These details can matter in some applications, for example, those which exploit side effects. And some readers may also find this background material to be helpful.
As a reminder,
when the semantics are applied to a parse tree,
they produce a value called a parse result.
Because Marpa allows ambiguous parsing,
each parse can produce a parse series -- a series of zero or more parse trees,
each with its own parse result.
The first call to the the recognizer's
value method after the recognizer is created is the start of the first parse series.
The first parse series continues until there is a call to the the
reset_evaluation method or until the recognizer is destroyed.
an application is only interested in a single parse series.
reset_evaluation method is called for a recognizer,
it begins a new parse series.
The new parse series continues until there is another call to the the
or until the recognizer is destroyed.
While processing a parse series, we have:
valuemethod for that series. It is followed by
While processing a parse tree, we have:
valuemethod for that parse tree. It is followed by
Node Evaluation Time is the Tree Traversal Phase, as seen from the point of view of each rule node. It is not a separate phase.
During the Series Setup Phase all value action names are resolved to value actions -- constants or rule evaluation closures. The rule evaluation closures are never called in the Series Setup Phase. They will be called later, in the Tree Traversal Phase. Also, during the Series Setup Phase, the logic which ranks parse trees is executed.
In the Tree Setup Phase,
the per-parse-tree variable is created.
If a constructor was found for the
it is run at this point,
and the per-parse-tree variable is its return value.
Exactly one Tree Setup Phase occurs for each parse tree.
During the Tree Traversal Phase, the rule evaluation closures are called. Node Evaluation Time is the Tree Traversal Phase, as seen from the point of view of the individual nodes of the parse tree.
Copyright 2013 Jeffrey Kegler This file is part of Marpa::R2. Marpa::R2 is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Marpa::R2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with Marpa::R2. If not, see http://www.gnu.org/licenses/.