@@ -106,7 +106,7 @@ def main(args=None):
106106 help = "Sets the program to be run once loaded" )
107107 parser .add_argument ('-A' , '--asm' , action = 'store_true' ,
108108 help = "Sets output format to asm" )
109- parser .add_argument ('-S' , '--org' , type = int , default = OPTIONS .org .value ,
109+ parser .add_argument ('-S' , '--org' , type = str , default = str ( OPTIONS .org .value ) ,
110110 help = "Start of machine code. By default %i" % OPTIONS .org .value )
111111 parser .add_argument ('-e' , '--errmsg' , type = str , dest = 'stderr' , default = OPTIONS .StdErrFileName .value ,
112112 help = 'Error messages file (standard error console by default)' )
@@ -144,6 +144,8 @@ def main(args=None):
144144 parser .add_argument ('--headerless' , action = 'store_true' ,
145145 help = 'Header-less mode: omit asm prologue and epilogue' )
146146 parser .add_argument ('--version' , action = 'version' , version = '%(prog)s {0}' .format (VERSION ))
147+ parser .add_argument ('--parse-only' , action = 'store_true' ,
148+ help = "Only parses to check for syntax and semantic errors" )
147149
148150 options = parser .parse_args (args = args )
149151
@@ -158,7 +160,6 @@ def main(args=None):
158160 OPTIONS .array_base .value = options .array_base
159161 OPTIONS .string_base .value = options .string_base
160162 OPTIONS .Sinclair .value = options .sinclair
161- OPTIONS .org .value = options .org
162163 OPTIONS .heap_size .value = options .heap_size
163164 OPTIONS .memoryCheck .value = options .debug_memory
164165 OPTIONS .strictBool .value = options .strict_bool or OPTIONS .Sinclair .value
@@ -170,6 +171,10 @@ def main(args=None):
170171 OPTIONS .strict .value = options .strict
171172 OPTIONS .headerless .value = options .headerless
172173
174+ OPTIONS .org .value = api .utils .parse_int (options .org )
175+ if OPTIONS .org .value is None :
176+ parser .error ("Invalid --org option '{}'" .format (options .org ))
177+
173178 if options .defines :
174179 for i in options .defines :
175180 name , val = tuple (i .split ('=' , 1 ))
@@ -187,8 +192,9 @@ def main(args=None):
187192
188193 debug .ENABLED = OPTIONS .Debug .value
189194
190- if int (options .tzx ) + int (options .tap ) + int (options .asm ) + int (options .emit_backend ) > 1 :
191- parser .error ("Options --tap, --tzx, --emit-backend and --asm are mutually exclusive" )
195+ if int (options .tzx ) + int (options .tap ) + int (options .asm ) + int (options .emit_backend ) + \
196+ int (options .parse_only ) > 1 :
197+ parser .error ("Options --tap, --tzx, --emit-backend, --parse-only and --asm are mutually exclusive" )
192198 return 3
193199
194200 if options .basic and not options .tzx and not options .tap :
@@ -319,7 +325,7 @@ def main(args=None):
319325 if options .asm : # Only output assembler file
320326 with open_file (OPTIONS .outputFileName .value , 'wt' , 'utf-8' ) as output_file :
321327 output (asm_output , output_file )
322- else :
328+ elif not options . parse_only :
323329 fout = StringIO ()
324330 output (asm_output , fout )
325331 asmparse .assemble (fout .getvalue ())
0 commit comments