예제 #1
0
    def _build_regexs(self, table):
        regexs = []
        for n, (token_type, text_regex) in enumerate(table):
            automaton = State.from_nfa(self.regex(text_regex))
            for state in automaton:
                if state.final: state.tag = (n, token_type)

            regexs.append(automaton)
        return regexs
예제 #2
0
    def _build_regexs(table):
        regexs = []
        for n, (token_type, regex) in enumerate(table):
            NFA = Regex.build_automaton(regex)
            automaton, states = State.from_nfa(NFA, get_states=True)
            for state in automaton:
                if state.final:
                    state.tag = [(n, token_type)]
            regexs.append(automaton)

        return regexs
예제 #3
0
    def _build_regexs(self, table):
        regexs = []
        for n, (token_type, regex) in enumerate(table):
            dfa = Regex(regex)
            automaton_list = State.from_nfa(
                dfa.automaton, 'texto random pra que haga lo que quiero')
            for i in automaton_list[1]:
                if (i.final):
                    i.tag = (n, token_type)
            regexs.append(automaton_list[0])

        return regexs
 def _build_regexs(self, table):
     regexs = {}
     for n, (token_type, regex) in enumerate(table):
         # Your code here!!!
         # - Remember to tag the final states with the token_type and priority.
         # - <State>.tag might be useful for that purpose ;-)
         auto = regex_automaton(regex)
         auto, states = State.from_nfa(auto, True)
         for st in states:
             if st.final:
                 st.tag = (n, token_type)
         regexs[token_type] = auto
     return regexs
예제 #5
0
    def _build_regexs(self, table):
        regexs = []
        for n, (token_type, regex) in enumerate(table):
            # Your code here!!!
            # - Remember to tag the final states with the token_type and priority.
            # - <State>.tag might be useful for that purpose ;-)
            NFA = _regex(regex)
            automaton, states = State.from_nfa(NFA, get_states=True)
            for state in states:
                if state.final:
                    state.tag = (n, token_type)
            regexs.append(automaton)

        return regexs