diff --git a/examples/logic/eval b/examples/logic/eval index dc41896..8884a28 100755 --- a/examples/logic/eval +++ b/examples/logic/eval @@ -6,8 +6,10 @@ import json as _json def evaluate(node): # _sys.stderr.write("eval: %s\n" % _json.dumps(node)) - if (node["label"] == "constant"): - return node["value"][0]["data"]["value"] + if (node["label"] == "constant_false"): + return False + elif (node["label"] == "constant_true"): + return True elif (node["label"] == "negation"): return (not evaluate(node["children"][0])) elif (node["label"] == "conjunction"): diff --git a/examples/logic/logic.tp2.json b/examples/logic/logic.tp2.json index ddb8af4..745d6f8 100644 --- a/examples/logic/logic.tp2.json +++ b/examples/logic/logic.tp2.json @@ -1,4 +1,5 @@ { + "version": "1", "lexer_rules": [ { "type": "ignore", @@ -7,19 +8,17 @@ } }, { - "type": "boolean", + "type": "string", "parameters": { "pattern": "false|0", - "id": "const", - "value": false + "id": "const_false" } }, { - "type": "boolean", + "type": "string", "parameters": { "pattern": "true|1", - "id": "const", - "value": true + "id": "const_true" } }, { @@ -60,10 +59,17 @@ ], "parser_rules": [ { - "label": "constant", + "label": "constant_false", "premise": "formula", "conclusion": [ - {"type": "terminal", "parameters": {"id": "const"}} + {"type": "terminal", "parameters": {"id": "const_false"}} + ] + }, + { + "label": "constant_true", + "premise": "formula", + "conclusion": [ + {"type": "terminal", "parameters": {"id": "const_true"}} ] }, {