aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdgar-Alexis-Lopez-Martinez <83847738+Edgar-Alexis-Lopez-Martinez@users.noreply.github.com>2022-11-07 22:14:28 -0600
committerGitHub <noreply@github.com>2022-11-07 22:14:28 -0600
commitcdadb350cdde2964b46e5dc6f524859b2afd9bee (patch)
tree19f19aa389e8babf37f39c21320d9a5e15da1d17
parent51c4a8c64d713b2b2e1d74d528744f2c06dd1fd6 (diff)
downloadjavanol-cdadb350cdde2964b46e5dc6f524859b2afd9bee.tar.gz
javanol-cdadb350cdde2964b46e5dc6f524859b2afd9bee.tar.bz2
javanol-cdadb350cdde2964b46e5dc6f524859b2afd9bee.zip
Create automata_flotantes.py
-rw-r--r--automata_flotantes.py87
1 files changed, 87 insertions, 0 deletions
diff --git a/automata_flotantes.py b/automata_flotantes.py
new file mode 100644
index 0000000..222f977
--- /dev/null
+++ b/automata_flotantes.py
@@ -0,0 +1,87 @@
+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