From d30c2eba03a5345a206581d3172c146cb5e98501 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Sat, 23 Feb 2013 13:59:53 +0200 Subject: Added script to compile Meson itself. --- compile_meson.py | 13 +++++++++++++ mparser.py | 21 +++++++++------------ 2 files changed, 22 insertions(+), 12 deletions(-) create mode 100755 compile_meson.py mode change 100755 => 100644 mparser.py diff --git a/compile_meson.py b/compile_meson.py new file mode 100755 index 000000000..79b949bf3 --- /dev/null +++ b/compile_meson.py @@ -0,0 +1,13 @@ +#!/usr/bin/python3 -tt + +# This file generates all files needed to run +# Meson. It does the equivalent of "make" in +# standard build systems. + +import os +import mparser + +fullfile = os.path.abspath(__file__) +fulldir = os.path.dirname(fullfile) + +mparser.generate_parser_files(fulldir) diff --git a/mparser.py b/mparser.py old mode 100755 new mode 100644 index 7a38ccf6c..499381fe8 --- a/mparser.py +++ b/mparser.py @@ -215,20 +215,17 @@ def test_lexer(): break print(tok) -def test_parser(): - code = """func_call('something', 'or else') - objectname.methodname(abc) - - emptycall()""" - print(build_ast(code)) +def generate_parser_files(outputdir): + code = """project('empty', 'c') +""" + build_ast(code, outputdir=outputdir) -def build_ast(code): +def build_ast(code, outputdir=None): code = code.rstrip() + '\n' lex.lex() - parser = yacc.yacc() + if outputdir: + parser = yacc.yacc(outputdir=outputdir) + else: + parser = yacc.yacc() result = parser.parse(code) return result - -if __name__ == '__main__': - #test_lexer() - test_parser() -- cgit v1.2.3