diff --git a/examples/arithmetics/readme.md b/examples/arithmetics/readme.md index 452d241..1dcbb36 100644 --- a/examples/arithmetics/readme.md +++ b/examples/arithmetics/readme.md @@ -1,5 +1,5 @@ ## Usage -- `cat examples/arithmetics/arithmetics.tp2 | tools/conv > /tmp/arithmetics.tp2.json` -- `echo '2+3' | build/type2 /tmp/arithmetics.tp2.json` -- `echo '(2+3)*5' | build/type2 /tmp/arithmetics.tp2.json | examples/arithmetics/eval` +- `cat arithmetics.tp2 | ../../tools/convert > /tmp/arithmetics.tp2.json` +- `echo '2+3' | type2 /tmp/arithmetics.tp2.json` +- `echo '(2+3)*5' | type2 /tmp/arithmetics.tp2.json | ./eval` diff --git a/examples/logic/logic.tp2 b/examples/logic/logic.tp2 new file mode 100644 index 0000000..c669e9b --- /dev/null +++ b/examples/logic/logic.tp2 @@ -0,0 +1,19 @@ +@1 + +[] : " |\t|\n" +[const_false] : "false|0" +[const_true] : "true|1" +[not] : "¬|-|\!|not" +[and] : "∧|&|and" +[or] : "∨|\||or" +[open] : "\(|\[" +[close] : "\)|\]" + +{constant_false} : : [const_false] +{constant_true} : : [const_true] +{negation} : : [not] +{conjunction} : : [and] +{disjunction} : : [or] +{priorised} : : [open] [close] + + diff --git a/examples/logic/logic.tp2.json b/examples/logic/logic.tp2.json deleted file mode 100644 index 745d6f8..0000000 --- a/examples/logic/logic.tp2.json +++ /dev/null @@ -1,113 +0,0 @@ -{ - "version": "1", - "lexer_rules": [ - { - "type": "ignore", - "parameters": { - "pattern": " |\\t|\\n" - } - }, - { - "type": "string", - "parameters": { - "pattern": "false|0", - "id": "const_false" - } - }, - { - "type": "string", - "parameters": { - "pattern": "true|1", - "id": "const_true" - } - }, - { - "type": "void", - "parameters": { - "pattern": "¬|-|\\!|not", - "id": "not" - } - }, - { - "type": "void", - "parameters": { - "pattern": "∧|&|and", - "id": "and" - } - }, - { - "type": "void", - "parameters": { - "pattern": "∨|\\||or", - "id": "or" - } - }, - { - "type": "void", - "parameters": { - "pattern": "\\(|\\[", - "id": "open" - } - }, - { - "type": "void", - "parameters": { - "pattern": "\\)|\\]", - "id": "close" - } - } - ], - "parser_rules": [ - { - "label": "constant_false", - "premise": "formula", - "conclusion": [ - {"type": "terminal", "parameters": {"id": "const_false"}} - ] - }, - { - "label": "constant_true", - "premise": "formula", - "conclusion": [ - {"type": "terminal", "parameters": {"id": "const_true"}} - ] - }, - { - "label": "negation", - "premise": "formula", - "conclusion": [ - {"type": "terminal", "parameters": {"id": "not"}}, - {"type": "variable", "parameters": {"id": "formula"}} - ] - }, - { - "label": "conjunction", - "premise": "formula", - "conclusion": [ - {"type": "variable", "parameters": {"id": "formula"}}, - {"type": "terminal", "parameters": {"id": "and"}}, - {"type": "variable", "parameters": {"id": "formula"}} - ] - }, - { - "label": "disjunction", - "premise": "formula", - "conclusion": [ - {"type": "variable", "parameters": {"id": "formula"}}, - {"type": "terminal", "parameters": {"id": "or"}}, - {"type": "variable", "parameters": {"id": "formula"}} - ] - }, - { - "label": "priorised", - "premise": "formula", - "conclusion": [ - {"type": "terminal", "parameters": {"id": "open"}}, - {"type": "variable", "parameters": {"id": "formula"}}, - {"type": "terminal", "parameters": {"id": "close"}} - ] - } - ], - "parser_start": "formula" -} - diff --git a/examples/logic/readme.md b/examples/logic/readme.md index 0e08ad0..799767c 100644 --- a/examples/logic/readme.md +++ b/examples/logic/readme.md @@ -1,5 +1,6 @@ ## Usage -- `echo '0&1' | build/type2 examples/logic/logic.tp2.json` -- `echo 'not (false and true)' | build/type2 examples/logic/logic.tp2.json | examples/logic/eval` +- `cat logic.tp2 | ../../tools/convert > /tmp/logic.tp2.json` +- `echo '0&1' | type2 /tmp/logic.tp2.json` +- `echo 'not (false and true)' | type2 /tmp/logic.tp2.json | ./eval`