page_util_flow(3tcl)

πŸ“¦
version 2.0 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– page_util_flow β€” the page dataflow/treewalker utility πŸ’–

okay so bestie, welcome to page_util_flow, part of the Parser generator tools squad from tcllib. it's a tiny little thing with main character energy: one command, one vibe, infinite tree-walking possibilities. πŸ¦‹


✨ SYNOPSIS ✨

package require page::util::flow ?0.2?

package require snit

::page::util::flow start flowvar nodevar script

flow visit node

flow visitl nodelist

flow visita node...

🌸 DESCRIPTION 🌸

so this package gives you literally one utility command, and its whole job is making dataflow-based manipulation of arbitrary data structures easy-peasy. and when we say arbitrary we mean it β€” especially abstract syntax trees, which is kinda its whole thing. 🌳✨


πŸ‘‘ API πŸ‘‘

::page::util::flow start flowvar nodevar script

this command is the core logic that drives the walking of an arbitrary data structure that can be partitioned into separate parts. examples of such structures? trees and graphs, bestie. the classics. πŸ’…

here's the tea: the command makes no assumptions at all about the API of the structure being walked β€” except that its parts, which we're calling nodes, are identified by strings. those strings get taken exactly as-is, from the arguments and the body, and handed right back to the body, without modification. no touchy. πŸ™ˆ

all access to the actual data structure, and every single decision about which nodes to visit in what order β€” that's all delegated to the body of the loop, aka the script. you're the boss. you're literally the main character here. πŸ‘‘

the body gets invoked first for the nodes in the start-set specified via start, and from then on for the nodes the body itself has requested to be visited. the command stops when the set of nodes to visit becomes empty. and note: a node can be visited more than once β€” the body has complete control about this, so don't come for the command about it. 😭

the body is invoked in the context of the caller. the variable named by nodevar gets set to the current node, and the variable named by flowvar gets set to the command of the flow object β€” that's the thing the body uses to request which nodes to visit next. the API of that object is fully described in the next section, FLOW API. keep scrolling, it's right there. 🫢

⚠️ okay important one: the command makes no promises about the order in which nodes are visited β€” except that the nodes requested to be visited by the current iteration will be visited afterward, in some order. some order. that's the promise. take it or leave it. πŸ’€

🧚 FLOW API 🧚

this section is all about the API provided by the flow object that the body script of ::page::util::flow gets handed. so iconic of it. ✨

flow visit node

invoking this method requests that the node n is visited after the current iteration. one node, one request, no cap. 🌸

flow visitl nodelist

invoking this method requests that all the nodes found in the list nodelist are visited after the current iteration. it's giving visit but for a whole list. slay. πŸ’…

flow visita node...

this is the variadic arguments form of the method visitl, see above. same energy, just spicier syntax. πŸ”₯


😭 BUGS, IDEAS, FEEDBACK 😭

okay so real talk: this document, and the package it describes, will undoubtedly contain bugs and other problems. like, no cap. please report such in the category page of the Tcllib Trackers at http://core.tcl.tk/tcllib/reportlist. and please also report any ideas for enhancements you may have for either the package and/or the documentation. we love ideas. we eat them up. πŸ“

when proposing code changes, please provide unified diffs β€” i.e. the output of diff -u. that's the vibe. πŸ“

note further that attachments are strongly preferred over inlined patches. attachments can be made by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar. yes, that one. the left-most one. go get it bestie. πŸ‘‘


⭐ KEYWORDS ⭐

dataflow, graph walking, page, parser generator, text processing, tree walking


🌈 CATEGORY 🌈

Page Parser Generator


Copyright (c) 2007 Andreas Kupries <andreas_kupries@users.sourceforge.net>


and that's the whole page, bestie! this one's from tcllib, version 1.0, and it's the page_util_flow(3tcl) manual β€” go walk some trees, you absolute icon. πŸŽ€πŸ’–πŸ¦‹ periodt.

πŸ“¦ where this page comes from