def main(argv): global OUTPUT, ID_TABLE, ENABLED ENABLED = True OUTPUT = '' if argv: CURRENT_FILE.append(argv[0]) else: CURRENT_FILE.append('<stdout>') if OPTIONS.Sinclair.value: OUTPUT += include_once(search_filename('sinclair.bas', 0), 0) if len(OUTPUT) and OUTPUT[-1] != '\n': OUTPUT += '\n' parser.parse(lexer = LEXER, debug = OPTIONS.Debug.value > 2) CURRENT_FILE.pop() OUTPUT += LEXER.include(CURRENT_FILE[-1]) if len(OUTPUT) and OUTPUT[-1] != '\n': OUTPUT += '\n' parser.parse(lexer = LEXER, debug = OPTIONS.Debug.value > 2) CURRENT_FILE.pop()
def filter(input, filename = '<internal>', state = 'INITIAL'): ''' Filter the input string thought the preprocessor. result is appended to OUTPUT global str ''' CURRENT_FILE.append(filename) LEXER.input(input, filename) LEXER.lex.begin(state) parser.parse(lexer = LEXER, debug = OPTIONS.Debug.value > 2) CURRENT_FILE.pop()
def p_include_once_ok(p): ''' include_file : include_once NEWLINE program _ENDFILE_ ''' p[0] = [p[1]] + p[3] + [p[4]] CURRENT_FILE.pop() # Remove top of the stack