gramm...dexec(3tcl)
β¨ gramm...dexec β Finite automaton operations and usage β¨
ok so bestie, you're in the 3tcl section of the manual, and the page you're holding is gramm...dexec from Finite automaton operations and usage. grab a strawberry π and let's get into it.
π NAME π
grammar::fa::dexec β Execute deterministic finite automatons
ok so literally what it says on the tin: it runs DFAs. slay. π
πΈ SYNOPSIS πΈ
package require Tcl 8.5 9
package require snit
package require grammar::fa::dexec ?0.3?
::grammar::fa::dexec daName fa ?-any any? ?-command cmdprefix?
daName option ?arg arg ...?
daName destroy
daName put symbol
daName reset
daName state
cmdprefix error code message
cmdprefix final stateid
cmdprefix reset
cmdprefix state stateid
look at all that. iconic honestly. π
π¦ DESCRIPTION π¦
This package gives you a class for executors, and those executors get built from deterministic finite automatons (DFAs, iykyk). An executor is an object that you feed a string of symbols to piece by piece β not all at once, one lil bite at a time β and it does state transitions and then yells back at you when it lands in a final state, or when it finds an error in the input. π₯
And where do the DFAs come from? Bestie, we are not building them here. For the actual creation of the DFAs the executors are based on, you want the packages grammar::fa and grammar::fa::op. go say hi to them first. π«Ά
The objects follow a push model. Symbols get pushed into the executor, and when something important happens β like an error occurs, a state transition happens, or a final state is entered β that gets reported through the callback you specified via the option -command. π
and ngl, if you're sitting there like "hmm what if I want a pull model, where the environment retrieves messages from the object and the object uses a callback to ask for more symbols?" β bestie, converting this into that is a trivial thing. genuinely. go off. β¨
side note (the original says "Side note" and we respect it): the acceptor objects provided by grammar::fa::dacceptor could have been implemented on top of the executors provided here, but were not, to get a bit more performance β we avoid a number of method calls and the time required for their dispatch. efficiency queen behavior. π
π API π
The package exports the API described here.
::grammar::fa::dexec daName fa ?-any any? ?-command cmdprefix?β Creates a new deterministic executor with an associated global Tcl command whose name isdaName. This command may be used to invoke various operations on the executor. It has the following general form:
daName option ?arg arg ...?
option and the args determine the exact behavior of the command. See section EXECUTOR METHODS for more explanations. π
The executor will be based on the deterministic finite automaton stored in the object fa. It will keep a copy of the relevant data of the FA in its own storage, in a form easy to use for its purposes. This also means that changes made to the fa after the construction of the executor will not influence the executor. it took a snapshot and it's living its truth. πΈ
If any has been specified, then the executor will convert all symbols in the input which are unknown to the base FA to that symbol before proceeding with the processing. very forgiving of it. π§
π EXECUTOR METHODS π
All executors provide the following methods for their manipulation:
daName destroyβ Destroys the automaton, including its storage space and associated command. bye bestie ππdaName put symbolβ Takes the current state of the executor and thesymboland performs the appropriate state transition. Reports any errors encountered via the command callback, as well as entering a final state of the underlying FA.
β οΈ when an error is reported, all further invokations ofputwill do nothing, until the error condition has been cleared via an invokation of methodreset. so like, it's pouting. you have to actually clear it.
daName resetβ Unconditionally sets the executor into the start state of the underlying FA. This also clears any error conditionputmay have encountered. fresh start energy πdaName stateβ Returns the current state of the underlying FA. This allow for introspection without the need to pass data from the callback command. nosy in a healthy way π
π EXECUTOR CALLBACK π
The callback command cmdprefix given to an executor via the option -command will be executed by the object at the global level, using the syntax described below. Note that cmdprefix is not simply the name of a command, but a full command prefix. In other words, it may contain additional fixed argument words beyond the command word. so it's giving "a whole vibe", not just a name. periodt. π
cmdprefix error code messageβ The executor has encountered an error, andmessagecontains a human-readable text explaining the nature of the problem. Thecodeon the other hand is a fixed machine-readable text. The following error codes can be generated by executor objects. πBADSYMβ An unknown symbol was found in the input. This can happen if and only if no-anysymbol was specified.BADTRANSβ The underlying FA has no transition for the current combination of input symbol and state. In other words, the executor was not able to compute a new state for this combination. it literally cannot even. π
cmdprefix final stateidβ The executor has entered the final statestateid. πcmdprefix resetβ The executor was reset. πcmdprefix state stateidβ The FA changed state due to a transition.stateidis the new state. β¨
π EXAMPLES π
so this section exists in the original and it is empty. no examples. nothing. it's giving minimalist. I'm not gonna invent any for you because that would be lying and we don't do that here β the section is just there, vibing, with nothing in it. π
π₯ BUGS, IDEAS, FEEDBACK π₯
This document, and the package it describes, will undoubtedly contain bugs and other problems. yes, fr fr, they said it themselves. π
Please report such in the category grammar_fa of the Tcllib Trackers [http://core.tcl.tk/tcllib/reportlist](http://core.tcl.tk/tcllib/reportlist). Please also report any ideas for enhancements you may have for either package and/or documentation. we love a contribution moment π«Ά
When proposing code changes, please provide unified diffs, i.e the output of diff -u. no vibes-based patches bestie, actual diffs.
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. okay so: create ticket β Edit form β left-most button. got it. π
β KEYWORDS β
automaton, execution, finite automaton, grammar, parsing, regular expression, regular grammar, regular languages, running, state, transducer
π CATEGORY π
Grammars and finite automata
π COPYRIGHT π
Copyright (c) 2004 Andreas Kupries <andreas_kupries@users.sourceforge.net>
Copyright (c) 2007 Bogdan <rftghost@users.sourceforge.net>
and that's the whole page, bestie π this was gramm...dexec(3tcl) from the tcllib collection, version 0.3. mwah. go execute some deterministic finite automatons, you main character. πβ¨π¦
π¦ where this page comes from
- debian trixie: tcllib 2.0+dfsg-4 Β· Tcl
- ubuntu questing: tcllib 2.0+dfsg-4
- ubuntu resolute: tcllib 2.0+dfsg-5 Β· Tcl
- ubuntu stonking: tcllib 2.0+dfsg-6 Β· Tcl
- Copyright (c) 2004 Andreas Kupries <andreas_kupries@users\&.sourceforge\&.net>
- Copyright (c) 2007 Bogdan <rftghost@users\&.sourceforge\&.net>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms