• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3
4# Copyright (c) 2021 Huawei Device Co., Ltd.
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17import optparse
18import subprocess
19
20if __name__ == '__main__':
21    print("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^")
22    parser_obj = optparse.OptionParser()
23    parser_obj.add_option("--scriptname",
24                      help="generate yacc script name",
25                      action="store_true", default=True)
26    parser_obj.add_option("--output",
27                      help="yacc output path",
28                      action="store_true", default="")
29    (option_list, parse_params) = parser_obj.parse_args()
30
31    if len(parse_params) < 1:
32        parser_obj.error("yacc param error.")
33
34    gen_script_name = parse_params[0]
35    output_path = parse_params[1]
36    parse_scripts = subprocess.check_call(
37        [gen_script_name], stdout=subprocess.PIPE, cwd=output_path)
38    print("result:", parse_scripts)
39