1
0
mirror of https://github.com/catseye/SixtyPical.git synced 2024-11-21 10:31:25 +00:00

Don't search for filenames given on cmdline in the include path.

This commit is contained in:
Chris Pressey 2019-10-23 10:32:26 +01:00
parent a9917d3ea8
commit 023a415a14
2 changed files with 8 additions and 7 deletions

View File

@ -31,7 +31,7 @@ def process_input_files(filenames, options):
programs = []
for filename in options.filenames:
program = load_program(filename, symtab, include_path)
program = load_program(filename, symtab, include_path, include_file=False)
if options.debug:
print(symtab)
programs.append(program)

View File

@ -101,7 +101,7 @@ class Parser(object):
while self.scanner.consume('include'):
filename = self.scanner.token
self.scanner.scan()
program = load_program(filename, self.symtab, self.include_path)
program = load_program(filename, self.symtab, self.include_path, include_file=True)
includes.append(program)
while self.scanner.on('typedef', 'const'):
if self.scanner.on('typedef'):
@ -480,12 +480,13 @@ class Parser(object):
# - - - -
def load_program(filename, symtab, include_path):
def load_program(filename, symtab, include_path, include_file=False):
import os
for include_dir in include_path:
if os.path.exists(os.path.join(include_dir, filename)):
filename = os.path.join(include_dir, filename)
break
if include_file:
for include_dir in include_path:
if os.path.exists(os.path.join(include_dir, filename)):
filename = os.path.join(include_dir, filename)
break
text = open(filename).read()
parser = Parser(symtab, text, filename, include_path)
program = parser.program()