Don't search for filenames given on cmdline in the include path.
Chris Pressey
3 years ago
30 | 30 |
programs = []
|
31 | 31 |
|
32 | 32 |
for filename in options.filenames:
|
33 | |
program = load_program(filename, symtab, include_path)
|
|
33 |
program = load_program(filename, symtab, include_path, include_file=False)
|
34 | 34 |
if options.debug:
|
35 | 35 |
print(symtab)
|
36 | 36 |
programs.append(program)
|
100 | 100 |
while self.scanner.consume('include'):
|
101 | 101 |
filename = self.scanner.token
|
102 | 102 |
self.scanner.scan()
|
103 | |
program = load_program(filename, self.symtab, self.include_path)
|
|
103 |
program = load_program(filename, self.symtab, self.include_path, include_file=True)
|
104 | 104 |
includes.append(program)
|
105 | 105 |
while self.scanner.on('typedef', 'const'):
|
106 | 106 |
if self.scanner.on('typedef'):
|
|
479 | 479 |
# - - - -
|
480 | 480 |
|
481 | 481 |
|
482 | |
def load_program(filename, symtab, include_path):
|
|
482 |
def load_program(filename, symtab, include_path, include_file=False):
|
483 | 483 |
import os
|
484 | |
for include_dir in include_path:
|
485 | |
if os.path.exists(os.path.join(include_dir, filename)):
|
486 | |
filename = os.path.join(include_dir, filename)
|
487 | |
break
|
|
484 |
if include_file:
|
|
485 |
for include_dir in include_path:
|
|
486 |
if os.path.exists(os.path.join(include_dir, filename)):
|
|
487 |
filename = os.path.join(include_dir, filename)
|
|
488 |
break
|
488 | 489 |
text = open(filename).read()
|
489 | 490 |
parser = Parser(symtab, text, filename, include_path)
|
490 | 491 |
program = parser.program()
|