Marpa:...Phases(3pm)

πŸ“¦
version 2.086000 Β· 4 versions
, in ubuntu jammy

πŸ’– 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 value method 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 value method 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 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