Beispiel #1
0
# Main method for Recursive descent Parser
# Creates parser object to actually validate syntax


import sys
from Parser import Parser

if __name__ == '__main__':
    file = sys.argv[1]
    with open(file,'r') as f:
        tokenStream = f.read().split('\n')
        print('Validating code...')
    prs = Parser([''], 0, True)
    for x in tokenStream:
        if x:
            s = x.split()
            prs.ts = s
            prs.line += 1
            prs.startProgram()
    if prs.valid:
        print('Validated with no errors.')
    else:
        print('Validated with errors.')