| 1 | #!/usr/bin/env python2
 | 
| 2 | """
 | 
| 3 | lexer_main.py
 | 
| 4 | """
 | 
| 5 | from __future__ import print_function
 | 
| 6 | 
 | 
| 7 | import os
 | 
| 8 | import sys
 | 
| 9 | 
 | 
| 10 | from _devbuild.gen.types_asdl import lex_mode_e
 | 
| 11 | 
 | 
| 12 | from core import alloc
 | 
| 13 | from core.pyerror import log
 | 
| 14 | from frontend import lexer
 | 
| 15 | from frontend import match
 | 
| 16 | 
 | 
| 17 | from typing import cast
 | 
| 18 | 
 | 
| 19 | 
 | 
| 20 | def run_tests():
 | 
| 21 |     # type: () -> None
 | 
| 22 | 
 | 
| 23 |     arena = alloc.Arena()
 | 
| 24 |     line_lexer = lexer.LineLexer('echo hi', arena)
 | 
| 25 | 
 | 
| 26 |     # Works!
 | 
| 27 |     tok = line_lexer.Read(lex_mode_e.ShCommand)
 | 
| 28 |     log("tok.val = '%s'", tok.val)
 | 
| 29 |     tok = line_lexer.Read(lex_mode_e.ShCommand)
 | 
| 30 |     log("tok.val = '%s'", tok.val)
 | 
| 31 |     tok = line_lexer.Read(lex_mode_e.ShCommand)
 | 
| 32 |     log("tok.val = '%s'", tok.val)
 | 
| 33 | 
 | 
| 34 |     # TODO: how to print Id_t?  With %r or something?
 | 
| 35 | 
 | 
| 36 | 
 | 
| 37 | def run_benchmarks():
 | 
| 38 |     # type: () -> None
 | 
| 39 |     pass
 | 
| 40 | 
 | 
| 41 | 
 | 
| 42 | if __name__ == '__main__':
 | 
| 43 |     if os.getenv('BENCHMARK'):
 | 
| 44 |         log('Benchmarking...')
 | 
| 45 |         run_benchmarks()
 | 
| 46 |     else:
 | 
| 47 |         run_tests()
 |