mirror of
https://github.com/catseye/SixtyPical.git
synced 2024-06-07 22:29:27 +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
|
import traceback
|
||||||
|
|
||||||
from sixtypical.symtab import SymbolTable
|
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.analyzer import Analyzer
|
||||||
from sixtypical.callgraph import construct_callgraph, prune_unreachable_routines
|
from sixtypical.callgraph import construct_callgraph, prune_unreachable_routines
|
||||||
from sixtypical.outputter import outputter_class_for
|
from sixtypical.outputter import outputter_class_for
|
||||||
|
@ -30,11 +30,9 @@ def process_input_files(filenames, options):
|
||||||
programs = []
|
programs = []
|
||||||
|
|
||||||
for filename in options.filenames:
|
for filename in options.filenames:
|
||||||
text = open(filename).read()
|
program = load_program(filename, symtab)
|
||||||
parser = Parser(symtab, text, filename)
|
|
||||||
if options.debug:
|
if options.debug:
|
||||||
print(symtab)
|
print(symtab)
|
||||||
program = parser.program()
|
|
||||||
programs.append(program)
|
programs.append(program)
|
||||||
|
|
||||||
if options.parse_only:
|
if options.parse_only:
|
||||||
|
|
|
@ -96,6 +96,12 @@ class Parser(object):
|
||||||
def program(self):
|
def program(self):
|
||||||
defns = []
|
defns = []
|
||||||
routines = []
|
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'):
|
while self.scanner.on('typedef', 'const'):
|
||||||
if self.scanner.on('typedef'):
|
if self.scanner.on('typedef'):
|
||||||
self.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):
|
def merge_programs(programs):
|
||||||
"""Assumes that the programs do not have any conflicts."""
|
"""Assumes that the programs do not have any conflicts."""
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user