-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtokens.py
More file actions
60 lines (42 loc) · 1.33 KB
/
Copy pathtokens.py
File metadata and controls
60 lines (42 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#! /usr/bin/python3
import re
COMMENT = "//"
AND = "and"
OR = "or"
RETURN = 'return'
""" type {identifier} = value"""
NUMBER = "num"
STRING = "string"
# class Declare:
# declared_variables = {}
# def __str__(self) -> str:
# return f'''
# variable_name : type
# {Declare.declared_variables}'''
# def register(self):
# if self._type == NUMBER:
# self.integer()
# elif self._type == STRING:
# self.string()
# else: raise Exception('invalid type')
# def __init__(self,line:str):
# self.command = line
# self.line = line.split(" ")
# self._type = self.line[0]
# self._identifier = self.line[1]
# self._value = self.line[-1]
# Declare.declared_variables[self._identifier] = self._type
# def integer(self):
# self._value = float(self._value)
# globals()[self._identifier] = self._value
# # print(self._identifier)
# def string(self):
# if '\"' in self._value or "\'" in self._value:
# globals()[self._identifier] = self._value
# else : raise Exception('invalid declare')
# a = Declare("string hello = '10'")
# # a = Declare("num helf = 10")
# # a = Declare("string hee = '10'")
# # a = Declare("num hel = 10")
# a.register()
# print(hello)