aboutsummaryrefslogtreecommitdiff
path: root/automata_cadenas.py
blob: 4f8a99b23b062e9a41649dfa3cafd86244ec702b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
class automata_cadena:
        int stateN = 0
        int isAccepted(char str[]):

            int len = len(str)
            
            for i in len:
                if (stateN == 0):
                    start(str[i])
                else: 
                    if (stateN == 1):
                        state1(str[i])
                    else: 
                        if (stateN == 2):
                            state2(str[i])   
                        else:
                            return 0

            if (stateN == 2):
                return 1
            else:
                return 0
            
            def start(char c):
                if (c == '\"'):
                    stateN = 1
                else:
                    stateN = -1
                
            def state1(char c):
                if (c != '\"'):
                    stateN = 1
                else:
                    stateN = 2
            
            def state2(char c):
                stateN = -1
            
            bool verified(char* token):
                if (isAccepted(token)):
                    return true
                else:
                    return false