aboutsummaryrefslogtreecommitdiff
path: root/compilador/automatas/automata_identificadores.py
diff options
context:
space:
mode:
Diffstat (limited to 'compilador/automatas/automata_identificadores.py')
-rw-r--r--compilador/automatas/automata_identificadores.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/compilador/automatas/automata_identificadores.py b/compilador/automatas/automata_identificadores.py
new file mode 100644
index 0000000..c26adfb
--- /dev/null
+++ b/compilador/automatas/automata_identificadores.py
@@ -0,0 +1,36 @@
+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