Marpa:...Phases(3pm)
π Marpa::R2::NAIF::Semantics::Phases π
okay bestie so this is a page from the User Contributed Perl Documentation set (it's a 3pm man page, we love that for her) and it's literally all about Details of NAIF parse evaluation. sit down, get a snack π, we're going in.
πΈ NAME πΈ
Marpa::R2::NAIF::Semantics::Phases β the details of NAIF parse evaluation. that's the whole name, she's thorough π
β¨ Overview of the semantic phases β¨
so real talk: this doc is about Marpa's low-level NAIF interface. and if you're new to Marpa, or you're not sure which interface you actually want, or you literally do not know what the Named Argment InterFace (NAIF) is β no stress, but you probably wanna go read the doc about semantics for the SLIF interface instead. this one is not your starter pack π«Ά
for most applications? the order in which Marpa's NAIF runs its semantics just works. iconic. but this doc spells out that order in detail, because the details can genuinely matter in some apps β for example, the ones that exploit side effects. and honestly some readers will just find this background material helpful on its own, which is valid β¨
this is an advanced document, fr fr. it's written assuming the more low-level NAIF interface is in use. the SLIF uses the same code as the NAIF for evaluation and works in the same way β except it hides even more of these details from you. shy queen π
π¦ Parse trees, parse results and parse series π¦
quick reminder bestie, because this matters: when the semantics are applied to a parse tree, they produce a value called a parse result.
and 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. zero!! could be none!! π
the first call to the recognizer's value method after the recognizer is created is the start of the first parse series. that first parse series keeps going until there's a call to the reset_evaluation method, or until the recognizer is destroyed. usually an application is only interested in a single parse series, which is so real of it.
when the reset_evaluation method is called for a recognizer, it begins a new parse series. and that new parse series continues until there's another call to the reset_evaluation method, or until the recognizer is destroyed. periodt. π
π Summary of the phases π
while processing a parse series, we have:
- a Series Setup Phase, which occurs during the first call of the recognizer's
valuemethod for that series. it is followed by - the processing of zero or more parse trees.
while processing a parse tree, we have:
- a Tree Setup Phase, which occurs during the call of the recognizer's
valuemethod for that parse tree. it is followed by - a Tree Traveral Phase.
and 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, bestie, do not be fooled π
π Series Setup Phase π
during the Series Setup Phase, all value action names are resolved to value actions β which are either constants or rule evaluation closures.
and listen: the rule evaluation closures are never called in the Series Setup Phase. never ever. they will be called later, in the Tree Traversal Phase.
also, during the Series Setup Phase, the logic which ranks parse trees is executed. she's multitasking β¨
πΈ Tree Setup Phase πΈ
in the Tree Setup Phase, the per-parse-tree variable is created.
if a constructor was found for the action_object, it is run at this point, and the per-parse-tree variable is its return value.
and bestie, exactly one Tree Setup Phase occurs for each parse tree. one. no more, no less. π
π Tree Traversal Phase π
during the Tree Traversal Phase, the rule evaluation closures are called.
and again, for the people in the back: Node Evaluation Time is the Tree Traversal Phase, as seen from the point of view of the individual nodes of the parse tree. same phase, different angle, main character energy π
π Copyright and License π
Copyright 2014 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/.
no cap: that WITHOUT ANY WARRANTY line is doing a lot of heavy lifting, so read it, bestie. it means what it says. π«Ά
that's the whole page, you ate it, you're an icon π
cute little sign-off for you: this was served up by perl v5.34.0, dated 2022-02-06, and it came to you as Marpa::...Phases(3pm) from the User Contributed Perl Documentation. mwah π
π¦ where this page comes from
- ubuntu jammy: libmarpa-r2-perl 2.086000~dfsg-7build1 Β· LGPL-3+~Marpa
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms