aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdgar-Alexis-Lopez-Martinez <83847738+Edgar-Alexis-Lopez-Martinez@users.noreply.github.com>2022-11-07 21:07:48 -0600
committerGitHub <noreply@github.com>2022-11-07 21:07:48 -0600
commitfa5994f682992c61e749091445cc072e871d9d46 (patch)
tree8ab40a33c4dfaa33aa5dd7038119ca6846f4ee33
parentfba2ad7934997eb62156533c0788ce7abae64302 (diff)
downloadjavanol-fa5994f682992c61e749091445cc072e871d9d46.tar.gz
javanol-fa5994f682992c61e749091445cc072e871d9d46.tar.bz2
javanol-fa5994f682992c61e749091445cc072e871d9d46.zip
Create automata_cadenas.py
-rw-r--r--automata_cadenas.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/automata_cadenas.py b/automata_cadenas.py
new file mode 100644
index 0000000..4f8a99b
--- /dev/null
+++ b/automata_cadenas.py
@@ -0,0 +1,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