aboutsummaryrefslogtreecommitdiff
path: root/automata_caracteres.py
diff options
context:
space:
mode:
authorEdgar-Alexis-Lopez-Martinez <83847738+Edgar-Alexis-Lopez-Martinez@users.noreply.github.com>2022-11-14 19:28:48 -0600
committerGitHub <noreply@github.com>2022-11-14 19:28:48 -0600
commitde272f939f2ae0266a4ee363a854558ace5a59e2 (patch)
tree2b37b82eb6133f44005dfb18e857eeae42211f80 /automata_caracteres.py
parentce60f5d0a018d9cb45d3c04cdbfd1bbfc14ae6b8 (diff)
downloadjavanol-de272f939f2ae0266a4ee363a854558ace5a59e2.tar.gz
javanol-de272f939f2ae0266a4ee363a854558ace5a59e2.tar.bz2
javanol-de272f939f2ae0266a4ee363a854558ace5a59e2.zip
Add Automatas
Automatas
Diffstat (limited to 'automata_caracteres.py')
-rw-r--r--automata_caracteres.py103
1 files changed, 51 insertions, 52 deletions
diff --git a/automata_caracteres.py b/automata_caracteres.py
index 0173467..341100a 100644
--- a/automata_caracteres.py
+++ b/automata_caracteres.py
@@ -1,52 +1,51 @@
-class automata_caracter:
- 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:
- return 0
-
- if (stateN == 3):
- return 1
- else:
- return 0
-
- def start(char c):
- if (c == '\''):
- stateN = 1
- else:
- stateN = -1
-
- def state1(char c):
- if (c != '\''):
- stateN = 2
- else:
- stateN = 3
-
- def state2(char c):
- if (c == '\''):
- stateN = 3
- else:
- stateN = -1
-
- def state3(char c):
- stateN = -1
-
- bool verified(char* token):
- if (isAccepted(token)):
- return true
- else:
- return false
+class automata_car:
+ stateN = 0
+
+
+ def isAccepted(self, _str):
+ i = len(_str)
+ _len = len(_str)
+
+ for i in range(len):
+ if self.stateN == 0:
+ self.start(_str[i])
+ if self.stateN == 1:
+ self.state1(_str[i])
+ if self.stateN == 2:
+ self.state2(_str[i])
+ if self.stateN == 3:
+ self.state3(_str[i])
+ else:
+ return 0
+ if self.stateN == 3:
+ return 1
+ else:
+ return 0
+
+ def start(self,c):
+ if (c == '\''):
+ self.stateN = 1
+ else:
+ self.stateN = -1
+
+ def state1(self,c):
+ if (c != '\''):
+ self.stateN = 2
+ else:
+ self.stateN = 3
+
+ def state2(self,c):
+ if (c == '\''):
+ self.stateN = 3
+ else:
+ self.stateN = -1
+
+ def state3(self,c):
+ self.stateN = -1
+
+ def verified(self,token){
+ if isAccepted(token):
+ return true
+ else:
+ return false
+ }