| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/env python |
| 2 # | |
| 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 6 | 5 |
| 7 """ Lexer for PPAPI IDL """ | 6 """ Lexer for PPAPI IDL """ |
| 8 | 7 |
| 9 # | 8 # |
| 10 # IDL Lexer | 9 # IDL Lexer |
| 11 # | 10 # |
| 12 # The lexer is uses the PLY lex library to build a tokenizer which understands | 11 # The lexer is uses the PLY lex library to build a tokenizer which understands |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 errors += 1 | 300 errors += 1 |
| 302 | 301 |
| 303 if not errors: | 302 if not errors: |
| 304 sys.stdout.write('Expect: Pass\n') | 303 sys.stdout.write('Expect: Pass\n') |
| 305 return 0 | 304 return 0 |
| 306 | 305 |
| 307 sys.stdout.write('Expect: Failed\n') | 306 sys.stdout.write('Expect: Failed\n') |
| 308 return -1 | 307 return -1 |
| 309 | 308 |
| 310 | 309 |
| 311 | |
| 312 | |
| 313 def Main(args): | 310 def Main(args): |
| 314 filenames = ParseOptions(args) | 311 filenames = ParseOptions(args) |
| 315 | 312 |
| 316 try: | 313 try: |
| 317 tokens = FilesToTokens(filenames, GetOption('verbose')) | 314 tokens = FilesToTokens(filenames, GetOption('verbose')) |
| 318 values = [tok.value for tok in tokens] | 315 values = [tok.value for tok in tokens] |
| 319 if GetOption('output'): sys.stdout.write(' <> '.join(values) + '\n') | 316 if GetOption('output'): sys.stdout.write(' <> '.join(values) + '\n') |
| 320 if GetOption('test'): | 317 if GetOption('test'): |
| 321 if TestSame(values): | 318 if TestSame(values): |
| 322 return -1 | 319 return -1 |
| 323 if TestExpect(tokens): | 320 if TestExpect(tokens): |
| 324 return -1 | 321 return -1 |
| 325 return 0 | 322 return 0 |
| 326 | 323 |
| 327 except lex.LexError as le: | 324 except lex.LexError as le: |
| 328 sys.stderr.write('%s\n' % str(le)) | 325 sys.stderr.write('%s\n' % str(le)) |
| 329 return -1 | 326 return -1 |
| 330 | 327 |
| 328 |
| 331 if __name__ == '__main__': | 329 if __name__ == '__main__': |
| 332 sys.exit(Main(sys.argv[1:])) | 330 sys.exit(Main(sys.argv[1:])) |
| OLD | NEW |