comparison python/yacc.py @ 322:44f336460c2a

Half of use of burg spec for arm
author Windel Bouwman
date Mon, 27 Jan 2014 19:58:07 +0100
parents 8c569fbe60e4
children e9fe6988497c
comparison
equal deleted inserted replaced
321:8c569fbe60e4 322:44f336460c2a
259 if semantics.strip() == '': 259 if semantics.strip() == '':
260 semantics = 'pass' 260 semantics = 'pass'
261 for n in range(M): 261 for n in range(M):
262 semantics = semantics.replace('${}'.format(n + 1), 'arg{}'.format(n + 1)) 262 semantics = semantics.replace('${}'.format(n + 1), 'arg{}'.format(n + 1))
263 self.print(' {}'.format(semantics)) 263 self.print(' {}'.format(semantics))
264 self.print('')
264 265
265 266
266 def make_argument_parser(): 267 def make_argument_parser():
267 # Parse arguments: 268 # Parse arguments:
268 parser = argparse.ArgumentParser(description='xacc compiler compiler') 269 parser = argparse.ArgumentParser(description='xacc compiler compiler')
269 parser.add_argument('source', type=argparse.FileType('r'), \ 270 parser.add_argument('source', type=argparse.FileType('r'), \
270 help='the parser specification') 271 help='the parser specification')
271 parser.add_argument('-o', '--output', type=argparse.FileType('w'), \ 272 parser.add_argument('-o', '--output', type=argparse.FileType('w'), \
272 default=sys.stdout) 273 default=sys.stdout)
274 return parser
273 275
274 276
275 def load_as_module(filename): 277 def load_as_module(filename):
276 """ Load a parser spec file, generate LR tables and create module """ 278 """ Load a parser spec file, generate LR tables and create module """
277 ob = io.StringIO() 279 ob = io.StringIO()