Currently job artifacts in CI/CD pipelines on LRZ GitLab never expire. Starting from Wed 26.1.2022 the default expiration time will be 30 days (GitLab default). Currently existing artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

Commit 618eef32 authored by Eckhart Arnold's avatar Eckhart Arnold
Browse files

- Arithmetic example extended

parent 44c61528
...@@ -18,9 +18,9 @@ ...@@ -18,9 +18,9 @@
# #
####################################################################### #######################################################################
expression = term { (PLUS|MINUS) term} expression = term { (PLUS | MINUS) term}
term = factor { (DIV|MUL) factor} term = factor { (DIV | MUL) factor}
factor = [sign] ( NUMBER | VARIABLE | group ) factor = [sign] (NUMBER | VARIABLE | group) { VARIABLE | group }
sign = POSITIVE | NEGATIVE sign = POSITIVE | NEGATIVE
group = "(" expression ")" group = "(" expression ")"
...@@ -32,7 +32,7 @@ group = "(" expression ")" ...@@ -32,7 +32,7 @@ group = "(" expression ")"
PLUS = "+" PLUS = "+"
MINUS = "-" MINUS = "-"
MUL = "*" | &factor # TODO: higher precedence of &factor MUL = "*"
DIV = "/" DIV = "/"
POSITIVE = /[+]/ # no implicit whitespace after signs POSITIVE = /[+]/ # no implicit whitespace after signs
......
...@@ -59,8 +59,7 @@ class ArithmeticGrammar(Grammar): ...@@ -59,8 +59,7 @@ class ArithmeticGrammar(Grammar):
r"""Parser for an Arithmetic source file. r"""Parser for an Arithmetic source file.
""" """
expression = Forward() expression = Forward()
factor = Forward() source_hash__ = "a8a1011bf1a9e1204d87031054b831f4"
source_hash__ = "6bca790f81db2b6dda4c92abdbe06d90"
static_analysis_pending__ = [True] static_analysis_pending__ = [True]
parser_initialization__ = ["upon instantiation"] parser_initialization__ = ["upon instantiation"]
resume_rules__ = {} resume_rules__ = {}
...@@ -74,12 +73,12 @@ class ArithmeticGrammar(Grammar): ...@@ -74,12 +73,12 @@ class ArithmeticGrammar(Grammar):
NEGATIVE = RegExp('[-]') NEGATIVE = RegExp('[-]')
POSITIVE = RegExp('[+]') POSITIVE = RegExp('[+]')
DIV = Series(Token("/"), dwsp__) DIV = Series(Token("/"), dwsp__)
MUL = Alternative(Series(DropToken("*"), dwsp__), Lookahead(factor)) MUL = Series(Token("*"), dwsp__)
MINUS = Series(Token("-"), dwsp__) MINUS = Series(Token("-"), dwsp__)
PLUS = Series(Token("+"), dwsp__) PLUS = Series(Token("+"), dwsp__)
group = Series(Series(DropToken("("), dwsp__), expression, Series(DropToken(")"), dwsp__)) group = Series(Series(DropToken("("), dwsp__), expression, Series(DropToken(")"), dwsp__))
sign = Alternative(POSITIVE, NEGATIVE) sign = Alternative(POSITIVE, NEGATIVE)
factor.set(Series(Option(sign), Alternative(NUMBER, VARIABLE, group))) factor = Series(Option(sign), Alternative(NUMBER, VARIABLE, group), ZeroOrMore(Alternative(VARIABLE, group)))
term = Series(factor, ZeroOrMore(Series(Alternative(DIV, MUL), factor))) term = Series(factor, ZeroOrMore(Series(Alternative(DIV, MUL), factor)))
expression.set(Series(term, ZeroOrMore(Series(Alternative(PLUS, MINUS), term)))) expression.set(Series(term, ZeroOrMore(Series(Alternative(PLUS, MINUS), term))))
root__ = expression root__ = expression
...@@ -108,11 +107,9 @@ def group_no_asterix_mul(context): ...@@ -108,11 +107,9 @@ def group_no_asterix_mul(context):
Arithmetic_AST_transformation_table = { Arithmetic_AST_transformation_table = {
# AST Transformations for the Arithmetic-grammar # AST Transformations for the Arithmetic-grammar
"expression": [left_associative, replace_by_single_child], "expression, term": [left_associative, replace_by_single_child],
"term": [left_associative, replace_by_single_child], "factor, sign": replace_by_single_child,
"factor": [replace_by_single_child],
"group": [remove_tokens('(', ')'), replace_by_single_child], "group": [remove_tokens('(', ')'), replace_by_single_child],
"sign": [replace_by_single_child]
} }
......
...@@ -14,6 +14,9 @@ M3: "-2.71828" ...@@ -14,6 +14,9 @@ M3: "-2.71828"
M4: "-x" M4: "-x"
M5: "(2 + x)" M5: "(2 + x)"
M6: "-(a * b)" M6: "-(a * b)"
M7: "2x"
M8: "-2x"
M9: "-(2 + 4)x(3 + 4)"
[fail:factor] [fail:factor]
F1: "x4" F1: "x4"
......
...@@ -24,7 +24,7 @@ except ModuleNotFoundError: ...@@ -24,7 +24,7 @@ except ModuleNotFoundError:
CONFIG_PRESET['ast_serialization'] = "S-expression" CONFIG_PRESET['ast_serialization'] = "S-expression"
CONFIG_PRESET['test_parallelization'] = False CONFIG_PRESET['test_parallelization'] = True
def recompile_grammar(grammar_src, force): def recompile_grammar(grammar_src, force):
grammar_tests_dir = os.path.join(scriptpath, 'grammar_tests') grammar_tests_dir = os.path.join(scriptpath, 'grammar_tests')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment