module Kleene::DSL
Extended Modules
Direct including types
Defined in:
dsl.crInstance Method Summary
-
#any(token_collection, alphabet = DEFAULT_ALPHABET)
two states: start state and final state structure: start state -> transitions for each token in the token collection -> final state
-
#append(a, b)
Append b onto a Appending produces a machine that matches all the strings in machine a followed by all the strings in machine b.
-
#append!(a, b)
Destructively append b onto a Appending produces a machine that matches all the strings in machine a followed by all the strings in machine b.
-
#dot(alphabet = DEFAULT_ALPHABET)
two states: start state and final state structure: start state -> transitions for every token in the alphabet -> final state
-
#kleene(machine)
Implements Kleene Star, as defined in the Ragel manual in section 2.5.6 of http://www.colm.net/files/ragel/ragel-guide-6.10.pdf: The machine resulting from the Kleene Star operator will match zero or more repetitions of the machine it is applied to.
-
#literal(token_stream : String, alphabet = DEFAULT_ALPHABET)
############## The following methods create FSAs given a stream of input tokens ################# given a string with N characters in it: N+1 states: start state and N other states structure: start state -> transition for first character in the string -> state for having observed first character in the string -> transition for second character in the string -> state for having observed second character in the string -> ...
- #optional(machine)
- #plus(machine)
-
#range(c_begin : Char, c_end : Char, alphabet = DEFAULT_ALPHABET)
This implements a character class, and is specifically for use with matching strings
-
#seq(a : NFA, b : NFA)
Implements concatenation, as defined in the Ragel manual in section 2.5.5 of http://www.colm.net/files/ragel/ragel-guide-6.10.pdf: Seq produces a machine that matches all the strings in machine
a
followed by all the strings in machineb
. - #seq(nfas : Array(NFA))
- #seq(*nfa_splat_tuple)
-
#union(nfas : Array(NFA))
Build a new machine consisting of a new start state with epsilon transitions to the start state of all the given NFAs in
nfas
. - #union(*nfa_splat_tuple)
-
#union!(nfas : Array(NFA))
same as union, but doesn't deep clone the constituent nfas
-
#with_err(nfa, alphabet = nfa.alphabet)
############## The following methods create FSAs given other FSAs ################# always clones the given nfa and returns a new nfa with a non-final error state
-
#with_err!(nfa, alphabet = nfa.alphabet)
adds and error state to the NFA, create error transitions from all non-error states to the error state on any unhandled token.
-
#with_err_dead_end(nfa, alphabet = nfa.alphabet)
always clones the given nfa and returns a new nfa with a non-final error state
-
#with_err_dead_end!(nfa, alphabet = nfa.alphabet)
adds and error state to the NFA, create error transitions from all non-error states to the error state on any unhandled token.
Instance Method Detail
two states: start state and final state structure: start state -> transitions for each token in the token collection -> final state
Append b onto a
Appending produces a machine that matches all the strings in machine a followed by all the strings in machine b.
This differs from #seq
in that the composite machine's final states are the union of machine a's final states and machine b's final states.
Destructively append b onto a
Appending produces a machine that matches all the strings in machine a followed by all the strings in machine b.
This differs from #seq
in that the composite machine's final states are the union of machine a's final states and machine b's final states.
two states: start state and final state structure: start state -> transitions for every token in the alphabet -> final state
Implements Kleene Star, as defined in the Ragel manual in section 2.5.6 of http://www.colm.net/files/ragel/ragel-guide-6.10.pdf: The machine resulting from the Kleene Star operator will match zero or more repetitions of the machine it is applied to. It creates a new start state and an additional final state. Epsilon transitions are drawn between the new start state and the old start state, between the new start state and the new final state, and between the final states of the machine and the new start state.
############## The following methods create FSAs given a stream of input tokens ################# given a string with N characters in it: N+1 states: start state and N other states structure: start state -> transition for first character in the string -> state for having observed first character in the string -> transition for second character in the string -> state for having observed second character in the string -> ... transition for last character in the string -> state for having observed last character in the string (marked final)
This implements a character class, and is specifically for use with matching strings
Implements concatenation, as defined in the Ragel manual in section 2.5.5 of http://www.colm.net/files/ragel/ragel-guide-6.10.pdf:
Seq produces a machine that matches all the strings in machine a
followed by all the strings in machine b
.
Seq draws epsilon transitions from the final states of thefirst machine to the start state of the second machine.
The final states of the first machine lose their final state status, unless the start state of the second machine is final as well.
Build a new machine consisting of a new start state with epsilon transitions to the start state of all the given NFAs in nfas
.
The resulting machine's final states are the set of final states from all the NFAs in nfas
.
Implements Union, as defined in the Ragel manual in section 2.5.1 of http://www.colm.net/files/ragel/ragel-guide-6.10.pdf: The union operation produces a machine that matches any string in machine one or machine two. The operation first creates a new start state. Epsilon transitions are drawn from the new start state to the start states of both input machines. The resulting machine has a final state setequivalent to the union of the final state sets of both input machines.
same as union, but doesn't deep clone the constituent nfas
############## The following methods create FSAs given other FSAs ################# always clones the given nfa and returns a new nfa with a non-final error state
adds and error state to the NFA, create error transitions from all non-error states to the error state on any unhandled token. the error state transitions to itself on any token.
always clones the given nfa and returns a new nfa with a non-final error state
adds and error state to the NFA, create error transitions from all non-error states to the error state on any unhandled token. the error state doesn't have any outbound transitions.