Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(391)

Side by Side Diff: Source/bindings/scripts/blink_idl_parser.py

Issue 332683004: IDL parser: fix rebuilding of (stale) cached parser tables (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (C) 2013 Google Inc. All rights reserved. 1 # Copyright (C) 2013 Google Inc. All rights reserved.
2 # 2 #
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer 10 # copyright notice, this list of conditions and the following disclaimer
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 return ls[1].value 373 return ls[1].value
374 374
375 if len(p) > 3: 375 if len(p) > 3:
376 p[0] = unwrap_string(p[1]) + p[2] + p[3] 376 p[0] = unwrap_string(p[1]) + p[2] + p[3]
377 else: 377 else:
378 p[0] = unwrap_string(p[1]) 378 p[0] = unwrap_string(p[1])
379 379
380 def __init__(self, 380 def __init__(self,
381 # common parameters 381 # common parameters
382 debug=False, 382 debug=False,
383 # local parameters
384 rewrite_tables=False,
383 # idl_parser parameters 385 # idl_parser parameters
384 lexer=None, verbose=False, mute_error=False, 386 lexer=None, verbose=False, mute_error=False,
385 # yacc parameters 387 # yacc parameters
386 outputdir='', optimize=True, write_tables=False, 388 outputdir='', optimize=True, write_tables=False,
387 picklefile=None): 389 picklefile=None):
388 if debug: 390 if debug:
389 # Turn off optimization and caching, and write out tables, 391 # Turn off optimization and caching, and write out tables,
390 # to help debugging 392 # to help debugging
391 optimize = False 393 optimize = False
392 outputdir = None 394 outputdir = None
393 picklefile = None 395 picklefile = None
394 write_tables = True 396 write_tables = True
395 if outputdir: 397 if outputdir:
396 picklefile = picklefile or os.path.join(outputdir, 'parsetab.pickle' ) 398 picklefile = picklefile or os.path.join(outputdir, 'parsetab.pickle' )
399 if rewrite_tables:
400 try:
401 os.unlink(picklefile)
402 except OSError:
403 pass
397 404
398 lexer = lexer or BlinkIDLLexer(debug=debug, 405 lexer = lexer or BlinkIDLLexer(debug=debug,
399 outputdir=outputdir, 406 outputdir=outputdir,
400 optimize=optimize) 407 optimize=optimize)
401 self.lexer = lexer 408 self.lexer = lexer
402 self.tokens = lexer.KnownTokens() 409 self.tokens = lexer.KnownTokens()
403 # Using SLR (instead of LALR) generates the table faster, 410 # Using SLR (instead of LALR) generates the table faster,
404 # but produces the same output. This is ok b/c Web IDL (and Blink IDL) 411 # but produces the same output. This is ok b/c Web IDL (and Blink IDL)
405 # is an SLR grammar (as is often the case for simple LL(1) grammars). 412 # is an SLR grammar (as is often the case for simple LL(1) grammars).
406 # 413 #
(...skipping 25 matching lines...) Expand all
432 439
433 ################################################################################ 440 ################################################################################
434 441
435 def main(argv): 442 def main(argv):
436 # If file itself executed, cache parse table 443 # If file itself executed, cache parse table
437 try: 444 try:
438 outputdir = argv[1] 445 outputdir = argv[1]
439 except IndexError as err: 446 except IndexError as err:
440 print 'Usage: %s OUTPUT_DIR' % argv[0] 447 print 'Usage: %s OUTPUT_DIR' % argv[0]
441 return 1 448 return 1
442 parser = BlinkIDLParser(outputdir=outputdir) 449 parser = BlinkIDLParser(outputdir=outputdir, rewrite_tables=True)
Nils Barth (inactive) 2014/06/23 11:05:14 Could you add a comment here explaining why this i
443 450
444 451
445 if __name__ == '__main__': 452 if __name__ == '__main__':
446 sys.exit(main(sys.argv)) 453 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698