git @ Cat's Eye Technologies SixtyPical / 175c077
First cut at include files. Chris Pressey 3 years ago
2 changed file(s) with 15 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
1616 import traceback
1717
1818 from sixtypical.symtab import SymbolTable
19 from sixtypical.parser import Parser, merge_programs
19 from sixtypical.parser import Parser, load_program, merge_programs
2020 from sixtypical.analyzer import Analyzer
2121 from sixtypical.callgraph import construct_callgraph, prune_unreachable_routines
2222 from sixtypical.outputter import outputter_class_for
2929 programs = []
3030
3131 for filename in options.filenames:
32 text = open(filename).read()
33 parser = Parser(symtab, text, filename)
32 program = load_program(filename, symtab)
3433 if options.debug:
3534 print(symtab)
36 program = parser.program()
3735 programs.append(program)
3836
3937 if options.parse_only:
9595 def program(self):
9696 defns = []
9797 routines = []
98 includes = []
99 while self.scanner.consume('include'):
100 filename = self.scanner.token
101 self.scanner.scan()
102 program = load_program(filename, self.symtab)
103 includes.append(program)
98104 while self.scanner.on('typedef', 'const'):
99105 if self.scanner.on('typedef'):
100106 self.typedef()
469475 # - - - -
470476
471477
478 def load_program(filename, symtab):
479 text = open(filename).read()
480 parser = Parser(symtab, text, filename)
481 program = parser.program()
482 return program
483
484
472485 def merge_programs(programs):
473486 """Assumes that the programs do not have any conflicts."""
474487