Lines Matching refs:state

6 #  rbbicst   Compile the RBBI rule paser state table data into initialized C data.
26 $num_states = 1; # Always the state number for the line being compiled.
29 $states{"pop"} = 255; # Add the "pop" to the list of defined state names.
30 # This prevents any state from being labelled with "pop",
31 # and resolves references to "pop" in the next state field.
54 # Does the first token end with a ":"? If so, it's the name of a state.
55 # Put in a hash, together with the current state number,
60 $state_name =~ s/://; # strip off the colon from the state name.
63 print " rbbicst: at line $line-num duplicate definition of state $state_name\n";
69 # otherwise assume that a state definition is on the same line and fall through.
80 # character [n] target-state [^push-state] [function-name]
87 $state_line_num[$num_states] = $line_num; # remember line number with each state
117 # do the destination state.
121 print " rbbicsts: at line $line_num, destination state missing.\n";
127 # do the push state, if present.
133 print " rbbicsts: at line $line_num, expected state after ^ (no spaces).\n";
159 # C source code for the state transition table.
161 # We read all states first, before writing anything, so that the state numbers
169 for ($state=1; $state < $num_states; $state++) {
170 if ($state_char_class[$state] ne "") {
171 if ($charClasses{$state_char_class[$state]} == 0) {
172 $charClasses{$state_char_class[$state]} = 1;
175 if ($state_func_name[$state] eq "") {
176 $state_func_name[$state] = "doNOP";
178 if ($actions{$state_action_name[$state]} == 0) {
179 $actions{$state_func_name[$state]} = 1;
187 $states{"exit"} = 0; # Predefined state name, terminates state machine.
188 for ($state=1; $state<$num_states; $state++) {
189 if ($states{$state_dest_state[$state]} == 0 && $state_dest_state[$state] ne "exit") {
190 print "Error at line $state_line_num[$state]: target state \"$state_dest_state[$state]\" is not defined.\n";
193 if ($state_push_state[$state] ne "" && $states{$state_push_state[$state]} == 0) {
194 print "Error at line $state_line_num[$state]: target state \"$state_push_state[$state]\" is not defined.\n";
204 # The values 0-127 in the state table are used for matching
208 # but trigger special handling by code in the state machine.
243 print " * This file contains the state table for the ICU Rule Based Break Iterator\n";
246 print " * the rule parser state definitions file \"rbbirpt.txt\".\n";
293 print " new RBBIRuleTableElement(doNOP, 0, 0,0, true, null ) // 0 \n"; #output the unused state 0.
294 for ($state=1; $state < $num_states; $state++) {
295 print " , new RBBIRuleTableElement($state_func_name[$state],";
296 if ($state_literal_chars[$state] ne "") {
297 $c = $state_literal_chars[$state];
300 print " $charClasses{$state_char_class[$state]},";
302 print " $states{$state_dest_state[$state]},";
304 # The push-state field is optional. If omitted, fill field with a zero, which flags
305 # the state machine that there is no push state.
306 if ($state_push_state[$state] eq "") {
309 print " $states{$state_push_state[$state]},";
311 print " $state_flag[$state], ";
313 # if this is the first row of the table for this state, put out the state name.
314 if ($stateNames[$state] ne "") {
315 print " \"$stateNames[$state]\") ";
320 # Put out a comment showing the number (index) of this state row,
321 print " // $state ";
339 print "// This file contains the state table for the ICU Rule Based Break Iterator\n";
342 print "// the rule parser state definitions file \"rbbirpt.txt\".\n";
384 print "// for the rule parser state machine.\n";
391 print " // 255: pop next-state from stack.\n";
397 # emit the state transition table
401 for ($state=1; $state < $num_states; $state++) {
402 print " , {$state_func_name[$state],";
403 if ($state_literal_chars[$state] ne "") {
404 $c = $state_literal_chars[$state];
407 print " $charClasses{$state_char_class[$state]},";
409 print " $states{$state_dest_state[$state]},";
411 # The push-state field is optional. If omitted, fill field with a zero, which flags
412 # the state machine that there is no push state.
413 if ($state_push_state[$state] eq "") {
416 print " $states{$state_push_state[$state]},";
418 print " $state_flag[$state]} ";
420 # Put out a C++ comment showing the number (index) of this state row,
421 # and, if this is the first row of the table for this state, the state name.
422 print " // $state ";
423 if ($stateNames[$state] ne "") {
424 print " $stateNames[$state]";
432 # emit a mapping array from state numbers to state names.
438 for ($state=0; $state<$num_states; $state++) {
439 if ($stateNames[$state] ne "") {
440 print " \"$stateNames[$state]\",\n";