comparison python/ppci/frontends/ks/parser.py @ 106:f2d980eef509

improved code generation
author Windel Bouwman
date Mon, 31 Dec 2012 18:26:56 +0100
parents 63937c8d1478
children 9e552d34bd60
comparison
equal deleted inserted replaced
105:6a303f835c6d 106:f2d980eef509
1 """
2 This module parses source code into an abstract syntax tree (AST)
3 """
4
5 from .symboltable import SymbolTable 1 from .symboltable import SymbolTable
6 from .nodes import * 2 from .nodes import *
7 from ...core.errors import CompilerException, Error 3 from ...core.errors import CompilerException, Error
8 from .builtin import * 4 from .builtin import *
9 #from . import assembler 5 #from . import assembler
10 from .lexer import tokenize 6 from .lexer import tokenize
11 7
12 class KsParser: 8 class KsParser:
9 """ This module parses source code into an abstract syntax tree (AST) """
13 def __init__(self, source): 10 def __init__(self, source):
14 """ provide the parser with the tokens iterator from the lexer. """ 11 """ provide the parser with the tokens iterator from the lexer. """
15 self.tokens = tokenize(source) # Lexical stage 12 self.tokens = tokenize(source) # Lexical stage
16 self.NextToken() 13 self.NextToken()
17 self.errorlist = [] 14 self.errorlist = []