diff options
author | Edgar-Alexis-Lopez-Martinez <83847738+Edgar-Alexis-Lopez-Martinez@users.noreply.github.com> | 2022-11-14 19:28:48 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-14 19:28:48 -0600 |
commit | de272f939f2ae0266a4ee363a854558ace5a59e2 (patch) | |
tree | 2b37b82eb6133f44005dfb18e857eeae42211f80 /automata_flotantes.py | |
parent | ce60f5d0a018d9cb45d3c04cdbfd1bbfc14ae6b8 (diff) | |
download | javanol-de272f939f2ae0266a4ee363a854558ace5a59e2.tar.gz javanol-de272f939f2ae0266a4ee363a854558ace5a59e2.tar.bz2 javanol-de272f939f2ae0266a4ee363a854558ace5a59e2.zip |
Add Automatas
Automatas
Diffstat (limited to 'automata_flotantes.py')
-rw-r--r-- | automata_flotantes.py | 165 |
1 files changed, 78 insertions, 87 deletions
diff --git a/automata_flotantes.py b/automata_flotantes.py index 222f977..5ba2b7d 100644 --- a/automata_flotantes.py +++ b/automata_flotantes.py @@ -1,87 +1,78 @@ -class automata_flotante: - 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 - return 0 - - if (stateN == 5): - return 1 - else: - return 0 - - def start(char c): - if (c == '0'): - stateN = 1 - else: - if(c == '-'): - stateN = 2 - else: - if(c == '1' or c == '2' or c == '3' or c == '4' or c == '5' or - c == '6' or c == '7' or c == '8' or c == '9'): - stateN = 3 - else: - stateN = -1 - - def state1(char c): - if (c == '.'): - stateN = 4 - else: - stateN = -1 - - def state2(char c): - if(c == '0'): - stateN = 1 - else: - if(c == '1' or c == '2' or c == '3' or c == '4' or c == '5' or - c == '6' or c == '7' or c == '8' or c == '9'): - stateN = 3 - else: - stateN = -1 - - def state3(char c): - if(c == '.'): - stateN = 4 - else: - if(isdigit(c)): - stateN = 3 - else: - stateN = -1 - - def state4(char c): - if(isdigit(c)): - stateN = 5 - else: - stateN = -1 - - def state5(char c): - if(isdigit(c)): - stateN = 5 - else: - stateN = -1 - - bool verified(char* token): - if (isAccepted(token)): - return true - else: - return false +class automata_flot:
+ 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])
+ if self.stateN == 4:
+ self.state4(_str[i])
+ if self.stateN == 5:
+ self.state5(_str[i])
+ else:
+ return 0
+
+ if self.stateN == 5:
+ return 1
+ else:
+ return 0
+
+ def start(self, c):
+ if (c == '0'):
+ self.stateN = 1
+ else if(c == '-'):
+ self.stateN = 2
+ else if(c == '1' or c == '2' or c == '3' or c == '4' or c == '5' or
+ c == '6' or c == '7' or c == '8' or c == '9'):
+ self.stateN = 3
+ else:
+ self.stateN = -1
+
+ def state1(self,c):
+ if (c == '.'):
+ self.stateN = 4
+ else:
+ self.stateN = -1
+
+ def state2(self,c):
+ if(c == '0'):
+ self.stateN = 1
+ else if(c == '1' or c == '2' or c == '3' or c == '4' or c == '5' or
+ c == '6' or c == '7' or c == '8' or c == '9'):
+ self.stateN = 3
+ else:
+ self.stateN = -1
+
+ def state3(self,c):
+ if(c == '.'):
+ self.stateN = 4
+ else if c.isdigit():
+ stateN = 3
+ else:
+ self.stateN = -1
+
+ def state4(self,c):
+ if c.isdigit():
+ self.stateN = 5
+ else:
+ self.stateN = -1
+
+ def state5(self,c):
+ if c.isdigit():
+ self.stateN = 5
+ else:
+ self.stateN = -1
+
+ def verified(self,token):
+ if isAccepted(token)
+ return true
+ else:
+ return false
\ No newline at end of file |