mirror of
https://github.com/catseye/SixtyPical.git
synced 2024-06-07 22:29:27 +00:00
Move merge_programs() out of main. Handle missing -o options.
This commit is contained in:
parent
8ce787a797
commit
0593ce6a66
|
@ -18,25 +18,12 @@ from pprint import pprint
|
|||
import sys
|
||||
import traceback
|
||||
|
||||
from sixtypical.parser import Parser, ParsingContext
|
||||
from sixtypical.parser import Parser, ParsingContext, merge_programs
|
||||
from sixtypical.analyzer import Analyzer
|
||||
from sixtypical.outputter import outputter_class_for
|
||||
from sixtypical.compiler import Compiler
|
||||
|
||||
|
||||
def merge_programs(programs):
|
||||
"""Assumes that the programs do not have any conflicts."""
|
||||
|
||||
from sixtypical.ast import Program
|
||||
|
||||
full = Program(1, defns=[], routines=[])
|
||||
for p in programs:
|
||||
full.defns.extend(p.defns)
|
||||
full.routines.extend(p.routines)
|
||||
|
||||
return full
|
||||
|
||||
|
||||
def process_input_files(filenames, options):
|
||||
context = ParsingContext()
|
||||
|
||||
|
@ -76,7 +63,7 @@ def process_input_files(filenames, options):
|
|||
compilation_roster = fa.serialize()
|
||||
dump(compilation_roster)
|
||||
|
||||
if options.analyze_only:
|
||||
if options.analyze_only or options.output is None:
|
||||
return
|
||||
|
||||
start_addr = None
|
||||
|
|
|
@ -479,3 +479,17 @@ class Parser(object):
|
|||
return SingleOp(self.scanner.line_number, opcode='trash', src=None, dest=dest)
|
||||
else:
|
||||
self.syntax_error('bad opcode "%s"' % self.scanner.token)
|
||||
|
||||
|
||||
# - - - -
|
||||
|
||||
|
||||
def merge_programs(programs):
|
||||
"""Assumes that the programs do not have any conflicts."""
|
||||
|
||||
full = Program(1, defns=[], routines=[])
|
||||
for p in programs:
|
||||
full.defns.extend(p.defns)
|
||||
full.routines.extend(p.routines)
|
||||
|
||||
return full
|
||||
|
|
Loading…
Reference in New Issue
Block a user