aboutsummaryrefslogtreecommitdiff
path: root/automata_identificadores.py
diff options
context:
space:
mode:
Diffstat (limited to 'automata_identificadores.py')
-rw-r--r--automata_identificadores.py73
1 files changed, 36 insertions, 37 deletions
diff --git a/automata_identificadores.py b/automata_identificadores.py
index 5e95429..7955616 100644
--- a/automata_identificadores.py
+++ b/automata_identificadores.py
@@ -1,37 +1,36 @@
-class automata_identificadores:
- 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:
- return 0
-
- if (stateN == 1):
- return 1
- else:
- return 0
-
- def start(char c):
- if (isalpha(c) or c == '_'):
- stateN = 1
- else:
- stateN = -1
-
- def state1(char c):
- if (isalpha(c) or c == '_' or isdigit(c)):
- stateN = 1
- else:
- stateN = -1
-
- bool no_es_main(char* token):
- if (isAccepted(token))
- return true
- else:
- return false
+class automata_ident:
+ 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])
+ else:
+ return 0
+ if self.stateN == 1:
+ return 1
+ else:
+ return 0
+
+ def start(self, c):
+ if (c.isalpha() or c == '_'):
+ self.stateN = 1
+ else:
+ self.stateN = -1
+
+ def state1(self, c):
+ if (c.isalpha() or c == '_' or c.isdigit()):
+ self.stateN = 1
+ else:
+ self.stateN = -1
+
+ def no_es_main(self,token):
+ if isAccepted(token):
+ return true
+ else:
+ return false \ No newline at end of file