grammar...cceptor(n)

πŸ“¦
version 2.0 Β· 2 versions
, in fedora 43, fedora 44, nixos 26.05, nixpkgs unstable

✨ grammar...cceptor(n) ✨

okay so bestie, welcome to grammar::cceptor β€” the Finite automaton operations and usage corner of the Tcllib universe 🌈. buckle up, this one's a lil niche but honestly kinda iconic πŸ’…


πŸ’– NAME πŸ’–

grammar::fa::dacceptor β€” make deterministic acceptors and then use them, no cap πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

package require Tcl 8.5 9

package require snit

package require struct::set

package require grammar::fa::dacceptor ?0.1.2?

::grammar::fa::dacceptor daName fa ?-any any?

daName option ?arg arg ...?

daName destroy

daName accept? symbols

🌸 DESCRIPTION 🌸

so this package hands you a class for acceptors that get built out of deterministic finite automatons (aka DFA, iykyk). An acceptor is just an object you can hand a string of symbols to, and it'll tell you whether the DFA it was built from would accept that string. yes, it's literally that girl πŸ’…

and if you're wondering how the DFAs themselves get made? that's not this package's job, bestie β€” for the actual creation of the DFAs the acceptors are based on, we've got the packages grammar::fa and grammar::fa::op. go say hi to them 🫢


πŸ‘‘ API πŸ‘‘

the package exports the API described here. yes, all of it. slay.

  • ::grammar::fa::dacceptor daName fa ?-any any? β€” creates a brand new deterministic acceptor with an associated global Tcl command whose name is daName. that command is your main character, and you use it to invoke all kinds of operations on the acceptor. its general form is:
daName option ?arg arg ...?

option and the *arg*s decide the exact behavior of the command β€” head down to ACCEPTOR METHODS for the full tea β˜•.

the acceptor will be based on the deterministic finite automaton stored in the object fa. and here's the important bit: it keeps a copy of the relevant data of the FA in its own storage, in a form that's easy to use for its purposes. which also means β€” and say it with me β€” changes made to the fa after the construction of the acceptor will not influence the acceptor. it said "I'm independent now" and honestly? respect πŸ’…

if any has been specified, then the acceptor will convert all symbols in the input which are unknown to the base FA to that symbol before proceeding with the processing. like a lil translator for the confused symbols, so sweet 🧚


πŸ’… ACCEPTOR METHODS πŸ’…

all acceptors provide the following methods for their manipulation:

  • daName destroy β€” destroys the automaton, including its storage space and associated command. gone. deleted. it's giving "we don't know her" πŸ’€
  • daName accept? symbols β€” takes the list of symbols and checks if the FA the acceptor is based on would accept it. the result is a boolean value. True comes back if the symbols are accepted, and False otherwise.

now pay attention bestie, this part matters: note that bogus symbols in the input are either translated to the any symbol (if specified), or cause the acceptance test to simply fail. no errors will be thrown β€” it just quietly says no πŸ™ˆ. and the method will process only just that prefix of the input which is enough to fully determine (non-)acceptance. efficient queen, she stops reading the second she knows the answer πŸ‘‘


🌈 EXAMPLES 🌈

this section is literally empty in the original, bestie 😭 no examples yet, we're manifesting them ✨

πŸ“ BUGS, IDEAS, FEEDBACK πŸ“

ngl this document, and the package it describes, will undoubtedly contain bugs and other problems. it's not a flaw, it's a personality 🫢

please report such in the category grammar_fa of the Tcllib Trackers [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 wanna hear it, fr fr πŸ’–

when proposing code changes, please provide unified diffs, i.e the output of diff -u. yes that exact thing, not vibes.

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. the left-most one. don't be shy about it πŸŽ€


⭐ KEYWORDS ⭐

acceptance, acceptor, automaton, finite automaton, grammar, parsing, regular expression, regular grammar, regular languages, state, transducer


🧚 CATEGORY 🧚

Grammars and finite automata


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


and that's the whole page bestie!! this lil icon dropped as part of tcllib, version 0.1.2, page grammar...cceptor(n) β€” go forth and accept strings, periodt πŸ’…βœ¨

πŸ“¦ where this page comes from