示例#1
0
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()
示例#2
0
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()
示例#3
0
def include_file(filename, lineno):
    ''' Writes down that "filename" was included at the current file, 
    at line <lineno>
    '''

    if filename not in INCLUDED.keys():
        INCLUDED[filename] = []

    if len(CURRENT_FILE) > 0:
        INCLUDED[filename].append((CURRENT_FILE[-1], lineno)) # Added from wich file, line

    CURRENT_FILE.append(filename)

    return LEXER.include(filename)