gramm...eptor(3tcl)

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

🌸 gramm...eptor(3tcl) 🌸

okay bestie, pull up a chair, we're doing the grammar::fa::dacceptor page from tcllib and honestly? it's giving iconic. the manual name is literally gramm...eptor(3tcl) and the whole vibe is "finite automaton operations and usage." let's go πŸ’…


✨ NAME ✨

grammar::fa::dacceptor β€” Create and use deterministic acceptors


✨ 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 built out of deterministic finite automatons (aka DFAs, iykyk). an acceptor is basically that friend who will look at a string of symbols and tell you, yes or no, whether the DFA it was built from would accept that string. no cap, that's the whole job. πŸŽ€

and if you want to actually make the DFAs these acceptors live on? that's a different errand β€” for that you want the packages grammar::fa and grammar::fa::op. πŸ¦‹


✨ API ✨

the package exports the API described right here, periodt.

  • ::grammar::fa::dacceptor daName fa ?-any any? β€” creates a brand new deterministic acceptor, and it comes with a global Tcl command whose name is daName. you use that command to run all sorts of operations on the acceptor. here's its general shape:
daName option ?arg arg ...?

so like… option and the args are what decide exactly what the command does. head down to the ACCEPTOR METHODS section for the full tea.

the acceptor gets based on the deterministic finite automaton stored in the object fa. and here's the important part: it keeps its own copy of the relevant data from that FA, in its own storage, in a form that's easy for it to work with. which means β€” and say it with me β€” any changes you make to fa after the acceptor is constructed will not influence the acceptor. it said "we're not doing that" πŸ’…

if any has been specified, then the acceptor converts every symbol in the input that's unknown to the base FA into that symbol before it carries on with the processing. cute, right? 🧚


✨ ACCEPTOR METHODS ✨

every acceptor gives you these methods to mess with it:

  • daName destroy β€” destroys the automaton, its storage space, and its associated command. all of it, gone, bye πŸ’€
  • daName accept? symbols β€” takes the list of symbols and checks whether the FA the acceptor is based on would accept it. the result is a boolean value: True if the symbols are accepted, False otherwise.

now listen, this part matters: bogus symbols in the input are either translated to the any symbol (if one was specified), or they just make the acceptance test straight-up fail. no errors will be thrown β€” it's not dramatic like that.

and the method is efficient about it too: it will process only just that prefix of the input which is enough to fully determine (non-)acceptance. main character energy, honestly. πŸ‘‘


✨ EXAMPLES ✨

okay so… there are no examples on this page. like, the section exists and then it just ends. nothing in it. not a single line. bestie I cannot make up examples for you, that would be lying, and we don't do that here πŸ™ˆ


✨ BUGS, IDEAS, FEEDBACK ✨

this document, and the package it describes, will undoubtedly contain bugs and other problems. obviously. it's software.

please report such things in the category grammar_fa 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. give us the ideas. 🫢

when proposing code changes, please provide unified diffs, i.e. the output of diff -u.

also note: attachments are strongly preferred over inlined patches. you can attach stuff by going to the Edit form of the ticket right after you create it, and then using the left-most button in the secondary navigation bar. yes, that one. the left-most one. πŸŽ€


✨ 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 one came to you from tcllib, version 0.1.2, page gramm...eptor(3tcl) β€” so go forth, accept some strings, reject some others, and slay πŸ’–βœ¨πŸŒˆ

πŸ“¦ where this page comes from