def build_minus_dfa(): return FiniteAutomata( [State(str(i)) for i in range(2)], [Symbol('-')], State('0'), [State('1')], [ [State('0'), Symbol('-'), State('1')], ] )
def build_close_par_dfa(): return FiniteAutomata( [State(str(i)) for i in range(2)], [Symbol(')')], State('0'), [State('1')], [ [State('0'), Symbol(')'), State('1')], ] )
def build_less_than_dfa(): return FiniteAutomata( [State(str(i)) for i in range(2)], [Symbol('<')], State('0'), [State('1')], [ [State('0'), Symbol("<"), State('1')], ] )
def build_delimiter_dfa(): return FiniteAutomata( [State(str(i)) for i in range(2)], [Symbol(";")], State('0'), [State('1')], [ [State('0'), Symbol(";"), State('1')], ] )
def build_greater_than_dfa(): return FiniteAutomata( [State(str(i)) for i in range(2)], [Symbol('>')], State('0'), [State('1')], [ [State('0'), Symbol(">"), State('1')], ] )
def build_open_brace_dfa(): return FiniteAutomata( [State(str(i)) for i in range(2)], [Symbol('{')], State('0'), [State('1')], [ [State('0'), Symbol('{'), State('1')], ] )
def build_assign_dfa(): return FiniteAutomata( [State(str(i)) for i in range(3)], [Symbol(':'), Symbol('=')], State('0'), [State('2')], [ [State('0'), Symbol(':'), State('1')], [State('1'), Symbol('='), State('2')], ] )
def build_not_equal_dfa(): return FiniteAutomata( [State(str(i)) for i in range(3)], [Symbol("="), Symbol('!')], State('0'), [State('2')], [ [State('0'), Symbol("!"), State('1')], [State('1'), Symbol("="), State('2')], ] )
def build_and_dfa(): return FiniteAutomata( [State(str(i)) for i in range(3)], [Symbol("&")], State('0'), [State('2')], [ [State('0'), Symbol("&"), State('1')], [State('1'), Symbol("&"), State('2')], ] )
def build_variable_dfa(): first_char = CharSet().range(65, 91).range(97, 123).char('_') rest_chars = CharSet().range(65, 91).range(97, 123).range(48, 58).char('_') return FiniteAutomata( [State(str(i)) for i in range(2)], [Symbol(first_char), Symbol(rest_chars)], State('0'), [State('1')], [ [State('0'), Symbol(first_char), State('1')], [State('1'), Symbol(rest_chars), State('1')], ] )
def build_else_dfa(): return FiniteAutomata( [State(str(i)) for i in range(5)], [ Symbol('e'), Symbol('l'), Symbol('s'), Symbol('e'), ], State('0'), [State('4')], [ [State('0'), Symbol('e'), State('1')], [State('1'), Symbol('l'), State('2')], [State('2'), Symbol('s'), State('3')], [State('3'), Symbol('e'), State('4')], ] )
def build_while_dfa(): return FiniteAutomata( [State(str(i)) for i in range(6)], [ Symbol('w'), Symbol('h'), Symbol('i'), Symbol('l'), Symbol('e') ], State('0'), [State('5')], [ [State('0'), Symbol('w'), State('1')], [State('1'), Symbol('h'), State('2')], [State('2'), Symbol('i'), State('3')], [State('3'), Symbol('l'), State('4')], [State('4'), Symbol('e'), State('5')], ] )
def build_number_dfa(): digits = CharSet().range(48, 58) return FiniteAutomata( [State(str(i)) for i in range(4)], [Symbol(digits), Symbol('.')], State('0'), [State('1'), State('3')], [ [State('0'), Symbol(digits), State('1')], [State('1'), Symbol(digits), State('1')], [State('1'), Symbol('.'), State('2')], [State('2'), Symbol(digits), State('3')], [State('3'), Symbol(digits), State('3')], ] )