-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSyntaxParser.py
More file actions
32 lines (26 loc) · 959 Bytes
/
SyntaxParser.py
File metadata and controls
32 lines (26 loc) · 959 Bytes
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
from interfaces.LexerRulesInterface import LexerRulesInterface
from domain.Component import Component
class SyntaxParser():
def __init__(self,
lexer_rules = None):
self.lexer_rules = lexer_rules
self.array_components = []
@staticmethod
def extract_component(self, line):
component = Component()
component.name = self.extract_name(line[1])
component.type = self.extract_type(line[0])
if component.name is not None and component.type is not None:
self.array_components.append(component)
@staticmethod
def extract_type(self, input_data: str):
#check in array
if input_data in self.lexer_rules.reserved_words:
return input_data
return None
@staticmethod
def extract_name(self, input_data: str):
#check in array
if input_data in self.array_components:
return input_data
return None