mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 16:41:07 +00:00
![Erik Ernst](/assets/img/avatar_default.png)
This makes it possible to run the spec parser in a way which is a bit more like the other tools that we have (e.g., tools/test.py): > tools/spec_parse.py tests/language/callable_test.dart It still requires the developer to run `make parser` in tools/spec_parser and hence does not run on a buildbot, but it's one step forward. Change-Id: I68ad6cea55bc02dddac21558acec33fc4bfc1981 Reviewed-on: https://dart-review.googlesource.com/9620 Commit-Queue: Erik Ernst <eernst@google.com> Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
51 lines
1.7 KiB
Python
Executable file
51 lines
1.7 KiB
Python
Executable file
#!/usr/bin/env python
|
|
#
|
|
# Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
|
|
# for details. All rights reserved. Use of this source code is governed by a
|
|
# BSD-style license that can be found in the LICENSE file.
|
|
|
|
# This script runs the parser which is generated using ANTLR 3 from
|
|
# docs/language/Dart.g. It relies on a certain environment and is hence
|
|
# usable locally where this environment can be obtained, but it may not be
|
|
# possible to run it, e.g., on build bots. The requirements are as follows:
|
|
#
|
|
# - `make parser` in spec_parser has been executed successfully.
|
|
# - A suitable JVM is in the PATH and may be executed as 'java'.
|
|
# - the ANTLR3 jar is available as /usr/share/java/antlr3-runtime.jar.
|
|
|
|
import os
|
|
import string
|
|
import subprocess
|
|
import sys
|
|
|
|
import utils
|
|
|
|
|
|
def Help(missing):
|
|
print('Execution of the spec parser failed. Missing: ' + missing)
|
|
print('Please read the comment near the top of spec_parse.py.\n')
|
|
sys.exit(1)
|
|
|
|
|
|
def Main():
|
|
args = sys.argv[1:]
|
|
tools_dir = os.path.dirname(os.path.realpath(__file__))
|
|
spec_parser_dir = os.path.join(tools_dir, 'spec_parser')
|
|
spec_parser_file = os.path.join(spec_parser_dir, 'SpecParser.class')
|
|
antlr_jar = '/usr/share/java/antlr3-runtime.jar'
|
|
class_path = string.join([spec_parser_dir, antlr_jar], ':')
|
|
command = ['java', '-cp', class_path, 'SpecParser'] + args
|
|
|
|
if not os.path.exists(antlr_jar): Help(antlr_jar)
|
|
if not os.path.exists(spec_parser_file): Help('"make parser" in spec_parser')
|
|
|
|
with utils.CoreDumpArchiver(args):
|
|
exit_code = subprocess.call(command)
|
|
|
|
utils.DiagnoseExitCode(exit_code, command)
|
|
return exit_code
|
|
|
|
|
|
if __name__ == '__main__':
|
|
sys.exit(Main())
|