from lexical_analyzer import LexicalAnalyzer
from parse_tree import ParseTree

if __name__ == '__main__':
    lexical_analyzer = LexicalAnalyzer('test.waffle')
    ParseTree(lexical_analyzer.tokens)

# Flow:
# File should be read as array of lines
# Lexical Analyzer cleans the comment lines, empty lines etc before starting the analysis (Preprocessor)
# Every line that lexical analyzer read from the program file is tokenized as a LexLine
# LexLines are appended as one dimensional array with $ symbols between the lines
# (This make us able to parse one line statements (assgnstat, returnstat etc) a lot easier in parsing phase)
# Tokens from the lexical analyzer passed to the Parse Tree class initializer
# Parser use the "get_next_token" to read the next token that that generated by Lexical Analyzer
# Parser in the parse tree class executes a top-down recursive descent parsing operation
# Parse Tree class also keeps the Symbol Table track while building the parse tree
# Some of the parser checks (flow control) are completed while parse tree is being built
# (Because building a non balanced tree is actually traversing an unknown tree)
# Some of the parser checks are being executed after the parse tree built (uniqueness, name-related)
# Any error in the lexical analysis or parsing won't stop the compiling process, only error messages will be printed

from lexical_analyzer import LexicalAnalyzer
from parse_tree import ParseTree

if __name__ == '__main__':
    lexical_analyzer = LexicalAnalyzer('test.waffle')
    ParseTree(lexical_analyzer.tokens)

# Flow:
# File should be read as array of lines
# Lexical Analyzer cleans the comment lines, empty lines etc before starting the analysis (Preprocessor)
# Every line that lexical analyzer read from the program file is tokenized as a LexLine
# LexLines are appended as one dimensional array with $ symbols between the lines
# (This make us able to parse one line statements (assgnstat, returnstat etc) a lot easier in parsing phase)
# Tokens from the lexical analyzer passed to the Parse Tree class initializer
# Parser use the "get_next_token" to read the next token that that generated by Lexical Analyzer
# Parser in the parse tree class executes a top-down recursive descent parsing operation
# Parse Tree class also keeps the Symbol Table track while building the parse tree
# Some of the parser checks (flow control) are completed while parse tree is being built
# (Because building a non balanced tree is actually traversing an unknown tree)
# Some of the parser checks are being executed after the parse tree built (uniqueness, name-related)
# Any error in the lexical analysis or parsing won't stop the compiling process, only error messages will be printed

# Flow: # File should be read as array of lines # Lexical Analyzer cleans the comment lines, empty lines etc before starting the analysis (Preprocessor) # Every line that lexical analyzer read from the program file is tokenized as a LexLine # LexLines are appended as one dimensional array with $ symbols between the lines # (This make us able to parse one line statements (assgnstat, returnstat etc) a lot easier in parsing phase) # Tokens from the lexical analyzer passed to the Parse Tree class initializer # Parser use the "get_next_token" to read the next token that that generated by Lexical Analyzer # Parser in the parse tree class executes a top-down recursive descent parsing operation # Parse Tree class also keeps the Symbol Table track while building the parse tree # Some of the parser checks (flow control) are completed while parse tree is being built # (Because building a non balanced tree is actually traversing an unknown tree) # Some of the parser checks are being executed after the parse tree built (uniqueness, name-related) # Any error in the lexical analysis or parsing won't stop the compiling process, only error messages will be printed