Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
spec_parse.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2#
3# Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
4# for details. All rights reserved. Use of this source code is governed by a
5# BSD-style license that can be found in the LICENSE file.
6
7# This script runs the parser which is generated using ANTLR 4 from
8# docs/language/Dart.g. It relies on a certain environment and is hence
9# usable locally where this environment can be obtained, but it may not be
10# possible to run it, e.g., on build bots. The requirements are as follows:
11#
12# - `make parser` in spec_parser has been executed successfully.
13# - A suitable JVM is in the PATH and may be executed as 'java'.
14# - the ANTLR3 jar is available as /usr/share/java/antlr4-runtime.jar.
15
16import os
17import subprocess
18import sys
19
20
21def Help(missing):
22 print('Execution of the spec parser failed. Missing: ' + missing)
23 print('Please read the comment near the top of spec_parse.py.\n')
24 sys.exit(1)
25
26
27def Main():
28 args = sys.argv[1:]
29 tools_dir = os.path.dirname(os.path.realpath(__file__))
30 spec_parser_dir = os.path.join(tools_dir, 'spec_parser')
31 spec_parser_file = os.path.join(spec_parser_dir, 'SpecParser.class')
32 antlr_jar = '/usr/share/java/antlr4-runtime.jar'
33 class_path = ':'.join([spec_parser_dir, antlr_jar])
34 command = ['java', '-cp', class_path, 'SpecParser'] + args
35
36 if not os.path.exists(antlr_jar): Help(antlr_jar)
37 if not os.path.exists(spec_parser_file):
38 Help('"make parser" in spec_parser')
39
40 return subprocess.call(command)
41
42
43if __name__ == '__main__':
44 sys.exit(Main())
void print(void *str)
Definition bridge.cpp:126
Help(missing)
Definition spec_parse.py:21