mirror of
https://github.com/catseye/SixtyPical.git
synced 2025-04-07 23:37:23 +00:00
First cut at include files.
This commit is contained in:
parent
987974cc21
commit
175c07781a
@ -17,7 +17,7 @@ from tempfile import NamedTemporaryFile
|
||||
import traceback
|
||||
|
||||
from sixtypical.symtab import SymbolTable
|
||||
from sixtypical.parser import Parser, merge_programs
|
||||
from sixtypical.parser import Parser, load_program, merge_programs
|
||||
from sixtypical.analyzer import Analyzer
|
||||
from sixtypical.callgraph import construct_callgraph, prune_unreachable_routines
|
||||
from sixtypical.outputter import outputter_class_for
|
||||
@ -30,11 +30,9 @@ def process_input_files(filenames, options):
|
||||
programs = []
|
||||
|
||||
for filename in options.filenames:
|
||||
text = open(filename).read()
|
||||
parser = Parser(symtab, text, filename)
|
||||
program = load_program(filename, symtab)
|
||||
if options.debug:
|
||||
print(symtab)
|
||||
program = parser.program()
|
||||
programs.append(program)
|
||||
|
||||
if options.parse_only:
|
||||
|
@ -96,6 +96,12 @@ class Parser(object):
|
||||
def program(self):
|
||||
defns = []
|
||||
routines = []
|
||||
includes = []
|
||||
while self.scanner.consume('include'):
|
||||
filename = self.scanner.token
|
||||
self.scanner.scan()
|
||||
program = load_program(filename, self.symtab)
|
||||
includes.append(program)
|
||||
while self.scanner.on('typedef', 'const'):
|
||||
if self.scanner.on('typedef'):
|
||||
self.typedef()
|
||||
@ -470,6 +476,13 @@ class Parser(object):
|
||||
# - - - -
|
||||
|
||||
|
||||
def load_program(filename, symtab):
|
||||
text = open(filename).read()
|
||||
parser = Parser(symtab, text, filename)
|
||||
program = parser.program()
|
||||
return program
|
||||
|
||||
|
||||
def merge_programs(programs):
|
||||
"""Assumes that the programs do not have any conflicts."""
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user