1grammar::fa::dexec(n)Finite automaton operations and usagegrammar::fa::dexec(n)
2
3
4
5______________________________________________________________________________
6
8 grammar::fa::dexec - Execute deterministic finite automatons
9
11 package require Tcl 8.4
12
13 package require snit
14
15 package require grammar::fa::dexec ?0.1.1?
16
17 ::grammar::fa::dexec daName fa ?-any any? ?-command cmdprefix?
18
19 daName option ?arg arg ...?
20
21 daName destroy
22
23 daName put symbol
24
25 daName reset
26
27 cmdprefix error code message
28
29 cmdprefix final stateid
30
31 cmdprefix reset
32
33_________________________________________________________________
34
36 This package provides a class for executors constructed from determin‐
37 istic finite automatons (DFA). Executors are objects which are given a
38 string of symbols in a piecemal fashion, perform state transitions and
39 report back when they enter a final state, or find an error in the
40 input. For the actual creation of the DFAs the executors are based on
41 we have the packages grammar::fa and grammar::fa::op.
42
43 The objects follow a push model. Symbols are pushed into the executor,
44 and when something important happens, i.e. and error occurs, or a final
45 state is entered this will be reported via the callback specified via
46 the option -command. Note that conversion of this into a pull model
47 where the environment retrieves messages from the object and the object
48 uses a callback to ask for more symbols is a trivial thing.
49
50 Side note: The acceptor objects provided by grammar::fa::dacceptor
51 could have been implemented on top of the executors provided here, but
52 were not, to get a bit more performance (we avoid a number of method
53 calls and the time required for their dispatch).
54
56 The package exports the API described here.
57
58 ::grammar::fa::dexec daName fa ?-any any? ?-command cmdprefix?
59 Creates a new deterministic executor with an associated global
60 Tcl command whose name is daName. This command may be used to
61 invoke various operations on the executor. It has the following
62 general form:
63
64 daName option ?arg arg ...?
65 Option and the args determine the exact behavior of the
66 command. See section EXECUTOR METHODS for more explana‐
67 tions.
68
69 The executor will be based on the deterministic finite
70 automaton stored in the object fa. It will keep a copy of
71 the relevant data of the FA in its own storage, in a form
72 easy to use for its purposes. This also means that
73 changes made to the fa after the construction of the
74 executor will not influence the executor.
75
76 If any has been specified, then the executor will convert
77 all symbols in the input which are unknown to the base FA
78 to that symbol before proceeding with the processing.
79
81 All executors provide the following methods for their manipulation:
82
83 daName destroy
84 Destroys the automaton, including its storage space and associ‐
85 ated command.
86
87 daName put symbol
88 Takes the current state of the executor and the symbol and per‐
89 forms the appropriate state transition. Reports any errors
90 encountered via the command callback, as well as entering a
91 final state of the underlying FA.
92
93 When an error is reported all further invokations of put will do
94 nothing, until the error condition has been cleared via an
95 invokation of method reset.
96
97 daName reset
98 Unconditionally sets the executor into the start state of the
99 underlying FA. This also clears any error condition put may
100 have encountered.
101
103 The callback command cmdprefix given to an executor via the option
104 -command will be executed by the object at the global level, using the
105 syntax described below. Note that cmdprefix is not simply the name of a
106 command, but a full command prefix. In other words it may contain addi‐
107 tional fixed argument words beyond the command word.
108
109 cmdprefix error code message
110 The executor has encountered an error, and message contains a
111 human-readable text explaining the nature of the problem. The
112 code on the other hand is a fixed machine-readable text. The
113 following error codes can be generated by executor objects.
114
115 BADSYM An unknown symbol was found in the input. This can happen
116 if and only if no -any symbol was specified.
117
118 BADTRANS
119 The underlying FA has no transition for the current com‐
120 bination of input symbol and state. In other words, the
121 executor was not able to compute a new state for this
122 combination.
123
124 cmdprefix final stateid
125 The executor has entered the final state stateid.
126
127 cmdprefix reset
128 The executor was reset.
129
132 automaton, execution, finite automaton, grammar, parsing, regular
133 expression, regular grammar, regular languages, running, state, trans‐
134 ducer
135
137 Copyright (c) 2004 Andreas Kupries <andreas_kupries@users.sourceforge.net>
138
139
140
141
142grammar_fa 0.1.1 grammar::fa::dexec(n)