Hi,
I'm trying to implement a python parser using PLY for the Kconfig language used to generate the configuration options for the linux kernel.
There's a keyword called source which performs an inclusion, so what i do is that when the lexer encounters this keyword, I change the lexer state to create a new lexer which is going to lex the sourced file:
def t_begin_source(t):
    r'source '
    t.lexer.begin('source')
def t_source_path(t):
    r'[^\n]+\n+'
    t.lexer.begin('INITIAL') 
    global path
    source_lexer = lex.lex(errorlog=lex.NullLogger())
    source_file_name = (path +  t.value.strip(' \"\n')) 
    sourced_file = file(path + t.value.strip(' \"\n')).read()
    source_lexer.input(sourced_file)
    while True:
        tok = source_lexer.token()
        if not tok:
            break
Somewhere else I have this line
lexer = lex.lex(errorlog=lex.NullLogger())
This is the "main" or "root" lexer which is going to be called by the parser.
My problem is that I don't know how to tell the parser to use a different lexer or to tell the "source_lexer" to return something...
Maybe the clone function should be used...
Thanks