예제 #1
0
class Parser(object):
    def __init__(self, text):
        self.lexer = Lexer(text)
        # set current token to the first token taken from the input
        self.current_token = self.lexer.get_next_token()

    def create_tree(self):
        """ create_tree: creates a tree from the Lexer"""
        self.tree = Tree()
        while self.current_token.type != EOF:
            self.tree.add_node(Node(self.current_token))
            self.current_token = self.lexer.get_next_token()
        print(self.tree)

    def parse(self):
        """ parse: creates Trees from the Lexer"""
        # TODO add support for multiple trees
        # The parser will maintain a list of trees
        self.create_tree()
예제 #2
0
파일: sam_parser.py 프로젝트: Oshiru/sam
class Parser(object):

    def __init__(self, text):
        self.lexer = Lexer(text)
        # set current token to the first token taken from the input
        self.current_token = self.lexer.get_next_token()

    def create_tree(self):
        """ create_tree: creates a tree from the Lexer"""
        self.tree = Tree()
        while self.current_token.type != EOF:
            self.tree.add_node(Node(self.current_token))
            self.current_token = self.lexer.get_next_token()
        print(self.tree)

    def parse(self):
        """ parse: creates Trees from the Lexer"""
        # TODO add support for multiple trees
        # The parser will maintain a list of trees
        self.create_tree()
예제 #3
0
파일: sam_parser.py 프로젝트: Oshiru/sam
 def __init__(self, text):
     self.lexer = Lexer(text)
     # set current token to the first token taken from the input
     self.current_token = self.lexer.get_next_token()
예제 #4
0
 def __init__(self, text):
     self.lexer = Lexer(text)
     # set current token to the first token taken from the input
     self.current_token = self.lexer.get_next_token()