aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdgar-Alexis-Lopez-Martinez <83847738+Edgar-Alexis-Lopez-Martinez@users.noreply.github.com>2022-11-07 22:23:12 -0600
committerGitHub <noreply@github.com>2022-11-07 22:23:12 -0600
commitf86a0e9ff5185874382e00d465931e5b78dd0874 (patch)
treefda627c4aa0ee5665bda84928560487a6c0a65fb
parentcdadb350cdde2964b46e5dc6f524859b2afd9bee (diff)
downloadjavanol-f86a0e9ff5185874382e00d465931e5b78dd0874.tar.gz
javanol-f86a0e9ff5185874382e00d465931e5b78dd0874.tar.bz2
javanol-f86a0e9ff5185874382e00d465931e5b78dd0874.zip
Create automata_operadores.py
-rw-r--r--automata_operadores.py109
1 files changed, 109 insertions, 0 deletions
diff --git a/automata_operadores.py b/automata_operadores.py
new file mode 100644
index 0000000..02d0ff9
--- /dev/null
+++ b/automata_operadores.py
@@ -0,0 +1,109 @@
+class automata_operador:
+ 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:
+ if (stateN == 3):
+ state3(str[i])
+ else:
+ if (stateN == 4):
+ state4(str[i])
+ else:
+ if (stateN == 5):
+ state5(str[i])
+ else:
+ if (stateN == 6):
+ state6(str[i])
+ else:
+ if (stateN == 7):
+ state7(str[i])
+ else:
+ if (stateN == 8):
+ state8(str[i])
+ else:
+ return 0
+
+ if (stateN == 1 or stateN == 7 or stateN == 8 or stateN == 2 or stateN == 3 or stateN == 6):
+ return 1
+ else:
+ return 0
+
+ def start(char c):
+ if(c == '=' or c == '>' or c == '<' or c == '/' or c == '*' or c == '%' or c == '!'):
+ stateN = 1
+ else:
+ if(c == '&'):
+ stateN = 4
+ else:
+ if(c == '|'):
+ stateN = 5
+ else:
+ if(c == '-'):
+ stateN = 6
+ else:
+ if(c == '+'):
+ stateN = 3
+ else
+ stateN = -1
+
+ def state1(char c):
+ if(c == '='):
+ stateN = 2
+ else:
+ stateN = -1
+
+ def state2(char c):
+ stateN = -1
+
+ def state3(char c):
+ if(c == '+'):
+ stateN = 7
+ else:
+ if(c == '=')
+ stateN = 2
+ else:
+ stateN = -1
+
+ def state4(char c):
+ if(c == '&'):
+ stateN = 2
+ else:
+ stateN = -1
+
+ def state5(char c):
+ if(c == '|'):
+ stateN = 2
+ else:
+ stateN = -1
+
+ def state6(char c):
+ if(c == '-'):
+ stateN = 8
+ else:
+ if(c == '=')
+ stateN = 2
+ else
+ stateN = -1
+
+ def state7(char c):
+ stateN = -1
+
+ def state8(char c):
+ stateN = -1
+
+ bool verified(char* token):
+ if (isAccepted(token)):
+ return true
+ else:
+ return false