diff --git a/README.md b/README.md
index 6af8a0c..f534446 100644
--- a/README.md
+++ b/README.md
@@ -198,7 +198,7 @@ pipenv --rm
## License
-Copyright © 2023 by Mausbrand Informationssysteme GmbH.
+Copyright © 2024 by Mausbrand Informationssysteme GmbH.
Mausbrand and ViUR are registered trademarks of Mausbrand Informationssysteme GmbH.
Logics is free software under the MIT license.
diff --git a/logics-js/package-lock.json b/logics-js/package-lock.json
index 5f64055..b0442f9 100644
--- a/logics-js/package-lock.json
+++ b/logics-js/package-lock.json
@@ -90,12 +90,13 @@
}
},
"node_modules/braces": {
- "version": "3.0.2",
- "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz",
- "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==",
+ "version": "3.0.3",
+ "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz",
+ "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==",
"dev": true,
+ "license": "MIT",
"dependencies": {
- "fill-range": "^7.0.1"
+ "fill-range": "^7.1.1"
},
"engines": {
"node": ">=8"
@@ -281,10 +282,11 @@
}
},
"node_modules/fill-range": {
- "version": "7.0.1",
- "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
- "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==",
+ "version": "7.1.1",
+ "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz",
+ "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==",
"dev": true,
+ "license": "MIT",
"dependencies": {
"to-regex-range": "^5.0.1"
},
@@ -323,6 +325,21 @@
"integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==",
"dev": true
},
+ "node_modules/fsevents": {
+ "version": "2.3.3",
+ "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
+ "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
+ "dev": true,
+ "hasInstallScript": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": "^8.16.0 || ^10.6.0 || >=11.0.0"
+ }
+ },
"node_modules/get-caller-file": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",
@@ -467,6 +484,7 @@
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
"dev": true,
+ "license": "MIT",
"engines": {
"node": ">=0.12.0"
}
@@ -815,6 +833,7 @@
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
"integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
"dev": true,
+ "license": "MIT",
"dependencies": {
"is-number": "^7.0.0"
},
diff --git a/logics-js/parser.js b/logics-js/parser.js
index 80fb808..d98a43d 100644
--- a/logics-js/parser.js
+++ b/logics-js/parser.js
@@ -1,4 +1,4 @@
-// Parser module generated by unicc from logics.par.
+// This parser module was generated by unicc from logics.par.
// DO NOT EDIT THIS FILE MANUALLY, IT WILL GO AWAY!
class LogicsNode {
@@ -114,8 +114,22 @@ export default class LogicsParser {
"is-whitespace": false,
"is-greedy": true,
},
- { symbol: "for", emit: "", "is-terminal": 2, "is-lexem": false, "is-whitespace": false, "is-greedy": true },
- { symbol: "$", emit: "", "is-terminal": 2, "is-lexem": false, "is-whitespace": false, "is-greedy": true },
+ {
+ symbol: "for",
+ emit: "",
+ "is-terminal": 2,
+ "is-lexem": false,
+ "is-whitespace": false,
+ "is-greedy": true,
+ },
+ {
+ symbol: "$",
+ emit: "",
+ "is-terminal": 2,
+ "is-lexem": false,
+ "is-whitespace": false,
+ "is-greedy": true,
+ },
{
symbol: "None",
emit: "None",
@@ -140,19 +154,110 @@ export default class LogicsParser {
"is-whitespace": false,
"is-greedy": true,
},
- { symbol: "**", emit: "", "is-terminal": 2, "is-lexem": false, "is-whitespace": false, "is-greedy": true },
- { symbol: "//", emit: "", "is-terminal": 2, "is-lexem": false, "is-whitespace": false, "is-greedy": true },
- { symbol: "in", emit: "", "is-terminal": 2, "is-lexem": false, "is-whitespace": false, "is-greedy": true },
- { symbol: "<>", emit: "", "is-terminal": 2, "is-lexem": false, "is-whitespace": false, "is-greedy": true },
- { symbol: "!=", emit: "", "is-terminal": 2, "is-lexem": false, "is-whitespace": false, "is-greedy": true },
- { symbol: "<=", emit: "", "is-terminal": 2, "is-lexem": false, "is-whitespace": false, "is-greedy": true },
- { symbol: "<", emit: "", "is-terminal": 2, "is-lexem": false, "is-whitespace": false, "is-greedy": true },
- { symbol: ">=", emit: "", "is-terminal": 2, "is-lexem": false, "is-whitespace": false, "is-greedy": true },
- { symbol: ">", emit: "", "is-terminal": 2, "is-lexem": false, "is-whitespace": false, "is-greedy": true },
- { symbol: "==", emit: "", "is-terminal": 2, "is-lexem": false, "is-whitespace": false, "is-greedy": true },
- { symbol: "not", emit: "", "is-terminal": 2, "is-lexem": false, "is-whitespace": false, "is-greedy": true },
- { symbol: "and", emit: "", "is-terminal": 2, "is-lexem": false, "is-whitespace": false, "is-greedy": true },
- { symbol: "or", emit: "", "is-terminal": 2, "is-lexem": false, "is-whitespace": false, "is-greedy": true },
+ {
+ symbol: "**",
+ emit: "",
+ "is-terminal": 2,
+ "is-lexem": false,
+ "is-whitespace": false,
+ "is-greedy": true,
+ },
+ {
+ symbol: "//",
+ emit: "",
+ "is-terminal": 2,
+ "is-lexem": false,
+ "is-whitespace": false,
+ "is-greedy": true,
+ },
+ {
+ symbol: "in",
+ emit: "",
+ "is-terminal": 2,
+ "is-lexem": false,
+ "is-whitespace": false,
+ "is-greedy": true,
+ },
+ {
+ symbol: "<>",
+ emit: "",
+ "is-terminal": 2,
+ "is-lexem": false,
+ "is-whitespace": false,
+ "is-greedy": true,
+ },
+ {
+ symbol: "!=",
+ emit: "",
+ "is-terminal": 2,
+ "is-lexem": false,
+ "is-whitespace": false,
+ "is-greedy": true,
+ },
+ {
+ symbol: "<=",
+ emit: "",
+ "is-terminal": 2,
+ "is-lexem": false,
+ "is-whitespace": false,
+ "is-greedy": true,
+ },
+ {
+ symbol: "<",
+ emit: "",
+ "is-terminal": 2,
+ "is-lexem": false,
+ "is-whitespace": false,
+ "is-greedy": true,
+ },
+ {
+ symbol: ">=",
+ emit: "",
+ "is-terminal": 2,
+ "is-lexem": false,
+ "is-whitespace": false,
+ "is-greedy": true,
+ },
+ {
+ symbol: ">",
+ emit: "",
+ "is-terminal": 2,
+ "is-lexem": false,
+ "is-whitespace": false,
+ "is-greedy": true,
+ },
+ {
+ symbol: "==",
+ emit: "",
+ "is-terminal": 2,
+ "is-lexem": false,
+ "is-whitespace": false,
+ "is-greedy": true,
+ },
+ {
+ symbol: "not",
+ emit: "",
+ "is-terminal": 2,
+ "is-lexem": false,
+ "is-whitespace": false,
+ "is-greedy": true,
+ },
+ {
+ symbol: "and",
+ emit: "",
+ "is-terminal": 2,
+ "is-lexem": false,
+ "is-whitespace": false,
+ "is-greedy": true,
+ },
+ {
+ symbol: "or",
+ emit: "",
+ "is-terminal": 2,
+ "is-lexem": false,
+ "is-whitespace": false,
+ "is-greedy": true,
+ },
{
symbol: "else",
emit: "",
@@ -161,7 +266,14 @@ export default class LogicsParser {
"is-whitespace": false,
"is-greedy": true,
},
- { symbol: "if", emit: "", "is-terminal": 2, "is-lexem": false, "is-whitespace": false, "is-greedy": true },
+ {
+ symbol: "if",
+ emit: "",
+ "is-terminal": 2,
+ "is-lexem": false,
+ "is-whitespace": false,
+ "is-greedy": true,
+ },
{
symbol: "String",
emit: "String",
@@ -194,19 +306,110 @@ export default class LogicsParser {
"is-whitespace": true,
"is-greedy": true,
},
- { symbol: ",", emit: "", "is-terminal": 1, "is-lexem": false, "is-whitespace": false, "is-greedy": true },
- { symbol: ".", emit: "", "is-terminal": 1, "is-lexem": false, "is-whitespace": false, "is-greedy": true },
- { symbol: ":", emit: "", "is-terminal": 1, "is-lexem": false, "is-whitespace": false, "is-greedy": true },
- { symbol: "]", emit: "", "is-terminal": 1, "is-lexem": false, "is-whitespace": false, "is-greedy": true },
- { symbol: "[", emit: "", "is-terminal": 1, "is-lexem": false, "is-whitespace": false, "is-greedy": true },
- { symbol: ")", emit: "", "is-terminal": 1, "is-lexem": false, "is-whitespace": false, "is-greedy": true },
- { symbol: "(", emit: "", "is-terminal": 1, "is-lexem": false, "is-whitespace": false, "is-greedy": true },
- { symbol: "~", emit: "", "is-terminal": 1, "is-lexem": false, "is-whitespace": false, "is-greedy": true },
- { symbol: "%", emit: "", "is-terminal": 1, "is-lexem": false, "is-whitespace": false, "is-greedy": true },
- { symbol: "/", emit: "", "is-terminal": 1, "is-lexem": false, "is-whitespace": false, "is-greedy": true },
- { symbol: "*", emit: "", "is-terminal": 1, "is-lexem": false, "is-whitespace": false, "is-greedy": true },
- { symbol: "-", emit: "", "is-terminal": 1, "is-lexem": false, "is-whitespace": false, "is-greedy": true },
- { symbol: "+", emit: "", "is-terminal": 1, "is-lexem": false, "is-whitespace": false, "is-greedy": true },
+ {
+ symbol: ",",
+ emit: "",
+ "is-terminal": 1,
+ "is-lexem": false,
+ "is-whitespace": false,
+ "is-greedy": true,
+ },
+ {
+ symbol: ".",
+ emit: "",
+ "is-terminal": 1,
+ "is-lexem": false,
+ "is-whitespace": false,
+ "is-greedy": true,
+ },
+ {
+ symbol: ":",
+ emit: "",
+ "is-terminal": 1,
+ "is-lexem": false,
+ "is-whitespace": false,
+ "is-greedy": true,
+ },
+ {
+ symbol: "]",
+ emit: "",
+ "is-terminal": 1,
+ "is-lexem": false,
+ "is-whitespace": false,
+ "is-greedy": true,
+ },
+ {
+ symbol: "[",
+ emit: "",
+ "is-terminal": 1,
+ "is-lexem": false,
+ "is-whitespace": false,
+ "is-greedy": true,
+ },
+ {
+ symbol: ")",
+ emit: "",
+ "is-terminal": 1,
+ "is-lexem": false,
+ "is-whitespace": false,
+ "is-greedy": true,
+ },
+ {
+ symbol: "(",
+ emit: "",
+ "is-terminal": 1,
+ "is-lexem": false,
+ "is-whitespace": false,
+ "is-greedy": true,
+ },
+ {
+ symbol: "~",
+ emit: "",
+ "is-terminal": 1,
+ "is-lexem": false,
+ "is-whitespace": false,
+ "is-greedy": true,
+ },
+ {
+ symbol: "%",
+ emit: "",
+ "is-terminal": 1,
+ "is-lexem": false,
+ "is-whitespace": false,
+ "is-greedy": true,
+ },
+ {
+ symbol: "/",
+ emit: "",
+ "is-terminal": 1,
+ "is-lexem": false,
+ "is-whitespace": false,
+ "is-greedy": true,
+ },
+ {
+ symbol: "*",
+ emit: "",
+ "is-terminal": 1,
+ "is-lexem": false,
+ "is-whitespace": false,
+ "is-greedy": true,
+ },
+ {
+ symbol: "-",
+ emit: "",
+ "is-terminal": 1,
+ "is-lexem": false,
+ "is-whitespace": false,
+ "is-greedy": true,
+ },
+ {
+ symbol: "+",
+ emit: "",
+ "is-terminal": 1,
+ "is-lexem": false,
+ "is-whitespace": false,
+ "is-greedy": true,
+ },
{
symbol: "expression'",
emit: "",
@@ -215,7 +418,14 @@ export default class LogicsParser {
"is-whitespace": false,
"is-greedy": true,
},
- { symbol: ",?", emit: "", "is-terminal": 0, "is-lexem": false, "is-whitespace": false, "is-greedy": true },
+ {
+ symbol: ",?",
+ emit: "",
+ "is-terminal": 0,
+ "is-lexem": false,
+ "is-whitespace": false,
+ "is-greedy": true,
+ },
{
symbol: "internal_list",
emit: "",
@@ -304,7 +514,14 @@ export default class LogicsParser {
"is-whitespace": false,
"is-greedy": true,
},
- { symbol: "pow", emit: "", "is-terminal": 0, "is-lexem": false, "is-whitespace": false, "is-greedy": true },
+ {
+ symbol: "pow",
+ emit: "",
+ "is-terminal": 0,
+ "is-lexem": false,
+ "is-whitespace": false,
+ "is-greedy": true,
+ },
{
symbol: "unary",
emit: "",
@@ -353,112 +570,480 @@ export default class LogicsParser {
"is-whitespace": false,
"is-greedy": true,
},
- { symbol: "cmp", emit: "", "is-terminal": 0, "is-lexem": false, "is-whitespace": false, "is-greedy": true },
- { symbol: "not", emit: "", "is-terminal": 0, "is-lexem": false, "is-whitespace": false, "is-greedy": true },
- { symbol: "and", emit: "", "is-terminal": 0, "is-lexem": false, "is-whitespace": false, "is-greedy": true },
- { symbol: "or", emit: "", "is-terminal": 0, "is-lexem": false, "is-whitespace": false, "is-greedy": true },
{
- symbol: "expression",
+ symbol: "cmp",
+ emit: "",
+ "is-terminal": 0,
+ "is-lexem": false,
+ "is-whitespace": false,
+ "is-greedy": true,
+ },
+ {
+ symbol: "not",
+ emit: "",
+ "is-terminal": 0,
+ "is-lexem": false,
+ "is-whitespace": false,
+ "is-greedy": true,
+ },
+ {
+ symbol: "and",
+ emit: "",
+ "is-terminal": 0,
+ "is-lexem": false,
+ "is-whitespace": false,
+ "is-greedy": true,
+ },
+ {
+ symbol: "or",
+ emit: "",
+ "is-terminal": 0,
+ "is-lexem": false,
+ "is-whitespace": false,
+ "is-greedy": true,
+ },
+ {
+ symbol: "expression",
+ emit: "",
+ "is-terminal": 0,
+ "is-lexem": false,
+ "is-whitespace": false,
+ "is-greedy": true,
+ },
+ ],
+ productions: [
+ {
+ production: 'expression : or "if" expression "else" expression',
+ emit: "if",
+ length: 5,
+ "left-hand-side": 62,
+ },
+ {
+ production: "expression : or",
+ emit: "",
+ length: 1,
+ "left-hand-side": 62,
+ },
+ {
+ production: 'or : or "or" and',
+ emit: "or",
+ length: 3,
+ "left-hand-side": 61,
+ },
+ {
+ production: "or : and",
+ emit: "",
+ length: 1,
+ "left-hand-side": 61,
+ },
+ {
+ production: 'and : and "and" not',
+ emit: "and",
+ length: 3,
+ "left-hand-side": 60,
+ },
+ {
+ production: "and : not",
+ emit: "",
+ length: 1,
+ "left-hand-side": 60,
+ },
+ {
+ production: 'not : "not" not',
+ emit: "not",
+ length: 2,
+ "left-hand-side": 59,
+ },
+ {
+ production: "not : cmp",
+ emit: "",
+ length: 1,
+ "left-hand-side": 59,
+ },
+ {
+ production: "cmp : add_sub &embedded_1+",
+ emit: "cmp",
+ length: 2,
+ "left-hand-side": 58,
+ },
+ {
+ production: '&embedded_1 : "==" add_sub',
+ emit: "eq",
+ length: 2,
+ "left-hand-side": 55,
+ },
+ {
+ production: '&embedded_1 : ">" add_sub',
+ emit: "gt",
+ length: 2,
+ "left-hand-side": 55,
+ },
+ {
+ production: '&embedded_1 : ">=" add_sub',
+ emit: "gteq",
+ length: 2,
+ "left-hand-side": 55,
+ },
+ {
+ production: '&embedded_1 : "<" add_sub',
+ emit: "lt",
+ length: 2,
+ "left-hand-side": 55,
+ },
+ {
+ production: '&embedded_1 : "<=" add_sub',
+ emit: "lteq",
+ length: 2,
+ "left-hand-side": 55,
+ },
+ {
+ production: '&embedded_0 : "!="',
+ emit: "",
+ length: 1,
+ "left-hand-side": 56,
+ },
+ {
+ production: '&embedded_0 : "<>"',
+ emit: "",
+ length: 1,
+ "left-hand-side": 56,
+ },
+ {
+ production: "&embedded_1 : &embedded_0 add_sub",
+ emit: "neq",
+ length: 2,
+ "left-hand-side": 55,
+ },
+ {
+ production: '&embedded_1 : "in" add_sub',
+ emit: "in",
+ length: 2,
+ "left-hand-side": 55,
+ },
+ {
+ production: '&embedded_1 : "not" "in" add_sub',
+ emit: "outer",
+ length: 3,
+ "left-hand-side": 55,
+ },
+ {
+ production: "&embedded_1+ : &embedded_1+ &embedded_1",
+ emit: "",
+ length: 2,
+ "left-hand-side": 54,
+ },
+ {
+ production: "&embedded_1+ : &embedded_1",
+ emit: "",
+ length: 1,
+ "left-hand-side": 54,
+ },
+ {
+ production: "cmp : add_sub",
+ emit: "",
+ length: 1,
+ "left-hand-side": 58,
+ },
+ {
+ production: "add_sub : add_sub '+' mul_div",
+ emit: "add",
+ length: 3,
+ "left-hand-side": 57,
+ },
+ {
+ production: "add_sub : add_sub '-' mul_div",
+ emit: "sub",
+ length: 3,
+ "left-hand-side": 57,
+ },
+ {
+ production: "add_sub : mul_div",
+ emit: "",
+ length: 1,
+ "left-hand-side": 57,
+ },
+ {
+ production: "mul_div : mul_div '*' unary",
+ emit: "mul",
+ length: 3,
+ "left-hand-side": 53,
+ },
+ {
+ production: "mul_div : mul_div '/' unary",
+ emit: "div",
+ length: 3,
+ "left-hand-side": 53,
+ },
+ {
+ production: 'mul_div : mul_div "//" unary',
+ emit: "idiv",
+ length: 3,
+ "left-hand-side": 53,
+ },
+ {
+ production: "mul_div : mul_div '%' unary",
+ emit: "mod",
+ length: 3,
+ "left-hand-side": 53,
+ },
+ {
+ production: "mul_div : pow",
+ emit: "",
+ length: 1,
+ "left-hand-side": 53,
+ },
+ {
+ production: 'pow : pow "**" unary',
+ emit: "pow",
+ length: 3,
+ "left-hand-side": 51,
+ },
+ {
+ production: "pow : unary",
+ emit: "",
+ length: 1,
+ "left-hand-side": 51,
+ },
+ {
+ production: "unary : '+' unary",
+ emit: "pos",
+ length: 2,
+ "left-hand-side": 52,
+ },
+ {
+ production: "unary : '-' unary",
+ emit: "neg",
+ length: 2,
+ "left-hand-side": 52,
+ },
+ {
+ production: "unary : '~' unary",
+ emit: "invert",
+ length: 2,
+ "left-hand-side": 52,
+ },
+ {
+ production: "unary : factor",
+ emit: "",
+ length: 1,
+ "left-hand-side": 52,
+ },
+ {
+ production: "factor : atom",
+ emit: "",
+ length: 1,
+ "left-hand-side": 50,
+ },
+ {
+ production: "factor : atom trailer+",
+ emit: "entity",
+ length: 2,
+ "left-hand-side": 50,
+ },
+ {
+ production: "trailer+ : trailer+ trailer",
+ emit: "",
+ length: 2,
+ "left-hand-side": 47,
+ },
+ {
+ production: "trailer+ : trailer",
+ emit: "",
+ length: 1,
+ "left-hand-side": 47,
+ },
+ {
+ production: "factor : @Identifier '(' list? ')'",
+ emit: "call",
+ length: 4,
+ "left-hand-side": 50,
+ },
+ {
+ production: "list? : list",
+ emit: "",
+ length: 1,
+ "left-hand-side": 45,
+ },
+ {
+ production: "list? : ",
+ emit: "",
+ length: 0,
+ "left-hand-side": 45,
+ },
+ {
+ production: "opt_expression : expression",
+ emit: "",
+ length: 1,
+ "left-hand-side": 44,
+ },
+ {
+ production: "opt_expression : ",
+ emit: "None",
+ length: 0,
+ "left-hand-side": 44,
+ },
+ {
+ production: "trailer : '[' expression ']'",
+ emit: "index",
+ length: 3,
+ "left-hand-side": 48,
+ },
+ {
+ production: "trailer : '[' opt_expression ':' opt_expression ']'",
+ emit: "slice",
+ length: 5,
+ "left-hand-side": 48,
+ },
+ {
+ production: "trailer : '.' @Identifier",
+ emit: "attr",
+ length: 2,
+ "left-hand-side": 48,
+ },
+ {
+ production: 'atom : "True"',
+ emit: "",
+ length: 1,
+ "left-hand-side": 49,
+ },
+ {
+ production: 'atom : "False"',
+ emit: "",
+ length: 1,
+ "left-hand-side": 49,
+ },
+ {
+ production: 'atom : "None"',
+ emit: "",
+ length: 1,
+ "left-hand-side": 49,
+ },
+ {
+ production: 'atom : "$"',
+ emit: "vars",
+ length: 1,
+ "left-hand-side": 49,
+ },
+ {
+ production: "atom : @Number",
+ emit: "",
+ length: 1,
+ "left-hand-side": 49,
+ },
+ {
+ production: "atom : @Identifier",
+ emit: "load",
+ length: 1,
+ "left-hand-side": 49,
+ },
+ {
+ production: "atom : @String",
+ emit: "",
+ length: 1,
+ "left-hand-side": 49,
+ },
+ {
+ production: "String+ : String+ @String",
+ emit: "",
+ length: 2,
+ "left-hand-side": 43,
+ },
+ {
+ production: "String+ : @String",
+ emit: "",
+ length: 1,
+ "left-hand-side": 43,
+ },
+ {
+ production: "atom : String+",
+ emit: "strings",
+ length: 1,
+ "left-hand-side": 49,
+ },
+ {
+ production: "atom : '[' expression \"for\" @Identifier \"in\" or &embedded_2? ']'",
+ emit: "comprehension",
+ length: 8,
+ "left-hand-side": 49,
+ },
+ {
+ production: '&embedded_2 : "if" expression',
+ emit: "",
+ length: 2,
+ "left-hand-side": 42,
+ },
+ {
+ production: "&embedded_2? : &embedded_2",
+ emit: "",
+ length: 1,
+ "left-hand-side": 41,
+ },
+ {
+ production: "&embedded_2? : ",
+ emit: "",
+ length: 0,
+ "left-hand-side": 41,
+ },
+ {
+ production: "atom : '[' list ']'",
+ emit: "",
+ length: 3,
+ "left-hand-side": 49,
+ },
+ {
+ production: "atom : '(' expression ',' ')'",
+ emit: "list",
+ length: 4,
+ "left-hand-side": 49,
+ },
+ {
+ production: "atom : '(' expression ',' internal_list ,? ')'",
+ emit: "list",
+ length: 6,
+ "left-hand-side": 49,
+ },
+ {
+ production: ",? : ','",
emit: "",
- "is-terminal": 0,
- "is-lexem": false,
- "is-whitespace": false,
- "is-greedy": true,
+ length: 1,
+ "left-hand-side": 39,
},
- ],
- productions: [
{
- production: 'expression : or "if" expression "else" expression',
- emit: "if",
- length: 5,
- "left-hand-side": 62,
+ production: ",? : ",
+ emit: "",
+ length: 0,
+ "left-hand-side": 39,
},
- { production: "expression : or", emit: "", length: 1, "left-hand-side": 62 },
- { production: 'or : or "or" and', emit: "or", length: 3, "left-hand-side": 61 },
- { production: "or : and", emit: "", length: 1, "left-hand-side": 61 },
- { production: 'and : and "and" not', emit: "and", length: 3, "left-hand-side": 60 },
- { production: "and : not", emit: "", length: 1, "left-hand-side": 60 },
- { production: 'not : "not" not', emit: "not", length: 2, "left-hand-side": 59 },
- { production: "not : cmp", emit: "", length: 1, "left-hand-side": 59 },
- { production: "cmp : add_sub &embedded_1+", emit: "cmp", length: 2, "left-hand-side": 58 },
- { production: '&embedded_1 : "==" add_sub', emit: "eq", length: 2, "left-hand-side": 55 },
- { production: '&embedded_1 : ">" add_sub', emit: "gt", length: 2, "left-hand-side": 55 },
- { production: '&embedded_1 : ">=" add_sub', emit: "gteq", length: 2, "left-hand-side": 55 },
- { production: '&embedded_1 : "<" add_sub', emit: "lt", length: 2, "left-hand-side": 55 },
- { production: '&embedded_1 : "<=" add_sub', emit: "lteq", length: 2, "left-hand-side": 55 },
- { production: '&embedded_0 : "!="', emit: "", length: 1, "left-hand-side": 56 },
- { production: '&embedded_0 : "<>"', emit: "", length: 1, "left-hand-side": 56 },
- { production: "&embedded_1 : &embedded_0 add_sub", emit: "neq", length: 2, "left-hand-side": 55 },
- { production: '&embedded_1 : "in" add_sub', emit: "in", length: 2, "left-hand-side": 55 },
- { production: '&embedded_1 : "not" "in" add_sub', emit: "outer", length: 3, "left-hand-side": 55 },
- { production: "&embedded_1+ : &embedded_1+ &embedded_1", emit: "", length: 2, "left-hand-side": 54 },
- { production: "&embedded_1+ : &embedded_1", emit: "", length: 1, "left-hand-side": 54 },
- { production: "cmp : add_sub", emit: "", length: 1, "left-hand-side": 58 },
- { production: "add_sub : add_sub '+' mul_div", emit: "add", length: 3, "left-hand-side": 57 },
- { production: "add_sub : add_sub '-' mul_div", emit: "sub", length: 3, "left-hand-side": 57 },
- { production: "add_sub : mul_div", emit: "", length: 1, "left-hand-side": 57 },
- { production: "mul_div : mul_div '*' unary", emit: "mul", length: 3, "left-hand-side": 53 },
- { production: "mul_div : mul_div '/' unary", emit: "div", length: 3, "left-hand-side": 53 },
- { production: 'mul_div : mul_div "//" unary', emit: "idiv", length: 3, "left-hand-side": 53 },
- { production: "mul_div : mul_div '%' unary", emit: "mod", length: 3, "left-hand-side": 53 },
- { production: "mul_div : pow", emit: "", length: 1, "left-hand-side": 53 },
- { production: 'pow : pow "**" unary', emit: "pow", length: 3, "left-hand-side": 51 },
- { production: "pow : unary", emit: "", length: 1, "left-hand-side": 51 },
- { production: "unary : '+' unary", emit: "pos", length: 2, "left-hand-side": 52 },
- { production: "unary : '-' unary", emit: "neg", length: 2, "left-hand-side": 52 },
- { production: "unary : '~' unary", emit: "invert", length: 2, "left-hand-side": 52 },
- { production: "unary : factor", emit: "", length: 1, "left-hand-side": 52 },
- { production: "factor : atom", emit: "", length: 1, "left-hand-side": 50 },
- { production: "factor : atom trailer+", emit: "entity", length: 2, "left-hand-side": 50 },
- { production: "trailer+ : trailer+ trailer", emit: "", length: 2, "left-hand-side": 47 },
- { production: "trailer+ : trailer", emit: "", length: 1, "left-hand-side": 47 },
- { production: "factor : @Identifier '(' list? ')'", emit: "call", length: 4, "left-hand-side": 50 },
- { production: "list? : list", emit: "", length: 1, "left-hand-side": 45 },
- { production: "list? : ", emit: "", length: 0, "left-hand-side": 45 },
- { production: "opt_expression : expression", emit: "", length: 1, "left-hand-side": 44 },
- { production: "opt_expression : ", emit: "None", length: 0, "left-hand-side": 44 },
- { production: "trailer : '[' expression ']'", emit: "index", length: 3, "left-hand-side": 48 },
{
- production: "trailer : '[' opt_expression ':' opt_expression ']'",
- emit: "slice",
- length: 5,
- "left-hand-side": 48,
+ production: "atom : '(' expression ')'",
+ emit: "",
+ length: 3,
+ "left-hand-side": 49,
},
- { production: "trailer : '.' @Identifier", emit: "attr", length: 2, "left-hand-side": 48 },
- { production: 'atom : "True"', emit: "", length: 1, "left-hand-side": 49 },
- { production: 'atom : "False"', emit: "", length: 1, "left-hand-side": 49 },
- { production: 'atom : "None"', emit: "", length: 1, "left-hand-side": 49 },
- { production: 'atom : "$"', emit: "vars", length: 1, "left-hand-side": 49 },
- { production: "atom : @Number", emit: "", length: 1, "left-hand-side": 49 },
- { production: "atom : @Identifier", emit: "load", length: 1, "left-hand-side": 49 },
- { production: "atom : @String", emit: "", length: 1, "left-hand-side": 49 },
- { production: "String+ : String+ @String", emit: "", length: 2, "left-hand-side": 43 },
- { production: "String+ : @String", emit: "", length: 1, "left-hand-side": 43 },
- { production: "atom : String+", emit: "strings", length: 1, "left-hand-side": 49 },
{
- production: "atom : '[' expression \"for\" @Identifier \"in\" or &embedded_2? ']'",
- emit: "comprehension",
- length: 8,
- "left-hand-side": 49,
+ production: "internal_list : expression",
+ emit: "",
+ length: 1,
+ "left-hand-side": 40,
},
- { production: '&embedded_2 : "if" expression', emit: "", length: 2, "left-hand-side": 42 },
- { production: "&embedded_2? : &embedded_2", emit: "", length: 1, "left-hand-side": 41 },
- { production: "&embedded_2? : ", emit: "", length: 0, "left-hand-side": 41 },
- { production: "atom : '[' list ']'", emit: "", length: 3, "left-hand-side": 49 },
- { production: "atom : '(' expression ',' ')'", emit: "list", length: 4, "left-hand-side": 49 },
{
- production: "atom : '(' expression ',' internal_list ,? ')'",
+ production: "internal_list : internal_list ',' expression",
+ emit: "",
+ length: 3,
+ "left-hand-side": 40,
+ },
+ {
+ production: "list : internal_list ,?",
emit: "list",
- length: 6,
- "left-hand-side": 49,
+ length: 2,
+ "left-hand-side": 46,
+ },
+ {
+ production: "expression' : expression ~&eof",
+ emit: "",
+ length: 2,
+ "left-hand-side": 38,
},
- { production: ",? : ','", emit: "", length: 1, "left-hand-side": 39 },
- { production: ",? : ", emit: "", length: 0, "left-hand-side": 39 },
- { production: "atom : '(' expression ')'", emit: "", length: 3, "left-hand-side": 49 },
- { production: "internal_list : expression", emit: "", length: 1, "left-hand-side": 40 },
- { production: "internal_list : internal_list ',' expression", emit: "", length: 3, "left-hand-side": 40 },
- { production: "list : internal_list ,?", emit: "list", length: 2, "left-hand-side": 46 },
- { production: "expression' : expression ~&eof", emit: "", length: 2, "left-hand-side": 38 },
],
goal: 38,
};
@@ -539,11 +1124,22 @@ export default class LogicsParser {
3: [3, 50],
2: [3, 51],
},
- { 31: [2, 17] },
- { 21: [1, 56] },
- { 0: [3, 71] },
- { 20: [2, 18], 18: [2, 19] },
- { 17: [2, 20] },
+ {
+ 31: [2, 17],
+ },
+ {
+ 21: [1, 56],
+ },
+ {
+ 0: [3, 71],
+ },
+ {
+ 20: [2, 18],
+ 18: [2, 19],
+ },
+ {
+ 17: [2, 20],
+ },
{
23: [2, 1],
22: [3, 52],
@@ -586,7 +1182,12 @@ export default class LogicsParser {
3: [3, 50],
2: [3, 51],
},
- { 35: [2, 32], 34: [2, 33], 7: [2, 34], 33: [2, 35] },
+ {
+ 35: [2, 32],
+ 34: [2, 33],
+ 7: [2, 34],
+ 33: [2, 35],
+ },
{
23: [2, 1],
22: [3, 52],
@@ -601,7 +1202,9 @@ export default class LogicsParser {
3: [3, 50],
2: [3, 51],
},
- { 6: [2, 36] },
+ {
+ 6: [2, 36],
+ },
{
23: [2, 1],
22: [3, 52],
@@ -616,7 +1219,10 @@ export default class LogicsParser {
3: [3, 50],
2: [3, 51],
},
- { 29: [2, 38], 26: [2, 39] },
+ {
+ 29: [2, 38],
+ 26: [2, 39],
+ },
{
23: [2, 1],
22: [3, 52],
@@ -647,7 +1253,9 @@ export default class LogicsParser {
3: [3, 50],
2: [3, 51],
},
- { 21: [3, 55] },
+ {
+ 21: [3, 55],
+ },
{
23: [2, 1],
22: [3, 52],
@@ -708,7 +1316,9 @@ export default class LogicsParser {
3: [3, 50],
2: [3, 51],
},
- { 8: [2, 47] },
+ {
+ 8: [2, 47],
+ },
{
23: [2, 1],
22: [3, 52],
@@ -916,7 +1526,10 @@ export default class LogicsParser {
3: [3, 50],
2: [3, 51],
},
- { 29: [2, 38], 26: [2, 39] },
+ {
+ 29: [2, 38],
+ 26: [2, 39],
+ },
{
23: [2, 1],
22: [3, 52],
@@ -932,14 +1545,31 @@ export default class LogicsParser {
3: [3, 50],
2: [3, 51],
},
- { 23: [3, 47] },
- { 30: [3, 67], 25: [2, 59] },
- { 1: [2, 60] },
- { 28: [3, 62] },
- { 25: [2, 61] },
- { 30: [3, 40] },
- { 19: [2, 62] },
- { 17: [2, 20] },
+ {
+ 23: [3, 47],
+ },
+ {
+ 30: [3, 67],
+ 25: [2, 59],
+ },
+ {
+ 1: [2, 60],
+ },
+ {
+ 28: [3, 62],
+ },
+ {
+ 25: [2, 61],
+ },
+ {
+ 30: [3, 40],
+ },
+ {
+ 19: [2, 62],
+ },
+ {
+ 17: [2, 20],
+ },
{
23: [2, 1],
22: [3, 52],
@@ -954,17 +1584,52 @@ export default class LogicsParser {
3: [3, 50],
2: [3, 51],
},
- { 37: [2, 30], 36: [2, 31] },
- { 37: [2, 30], 36: [2, 31] },
- { 37: [2, 30], 36: [2, 31] },
- { 37: [2, 30], 36: [2, 31] },
- { 37: [2, 30], 36: [2, 31] },
- { 37: [2, 30], 36: [2, 31] },
- { 37: [2, 30], 36: [2, 31] },
- { 35: [2, 32], 34: [2, 33], 7: [2, 34], 33: [2, 35] },
- { 35: [2, 32], 34: [2, 33], 7: [2, 34], 33: [2, 35] },
- { 28: [3, 45] },
- { 27: [2, 64] },
+ {
+ 37: [2, 30],
+ 36: [2, 31],
+ },
+ {
+ 37: [2, 30],
+ 36: [2, 31],
+ },
+ {
+ 37: [2, 30],
+ 36: [2, 31],
+ },
+ {
+ 37: [2, 30],
+ 36: [2, 31],
+ },
+ {
+ 37: [2, 30],
+ 36: [2, 31],
+ },
+ {
+ 37: [2, 30],
+ 36: [2, 31],
+ },
+ {
+ 37: [2, 30],
+ 36: [2, 31],
+ },
+ {
+ 35: [2, 32],
+ 34: [2, 33],
+ 7: [2, 34],
+ 33: [2, 35],
+ },
+ {
+ 35: [2, 32],
+ 34: [2, 33],
+ 7: [2, 34],
+ 33: [2, 35],
+ },
+ {
+ 28: [3, 45],
+ },
+ {
+ 27: [2, 64],
+ },
{
23: [2, 1],
22: [3, 52],
@@ -981,7 +1646,9 @@ export default class LogicsParser {
3: [3, 50],
2: [3, 51],
},
- { 23: [2, 66] },
+ {
+ 23: [2, 66],
+ },
{
23: [2, 1],
22: [3, 52],
@@ -1012,7 +1679,10 @@ export default class LogicsParser {
3: [3, 50],
2: [3, 51],
},
- { 37: [2, 30], 36: [2, 31] },
+ {
+ 37: [2, 30],
+ 36: [2, 31],
+ },
{
23: [2, 1],
22: [3, 52],
@@ -1028,10 +1698,18 @@ export default class LogicsParser {
3: [3, 50],
2: [3, 51],
},
- { 25: [2, 61] },
- { 8: [2, 69] },
- { 28: [3, 46] },
- { 30: [3, 64] },
+ {
+ 25: [2, 61],
+ },
+ {
+ 8: [2, 69],
+ },
+ {
+ 28: [3, 46],
+ },
+ {
+ 30: [3, 64],
+ },
{
23: [2, 1],
22: [3, 52],
@@ -1047,7 +1725,10 @@ export default class LogicsParser {
3: [3, 50],
2: [3, 51],
},
- { 20: [2, 71], 18: [2, 19] },
+ {
+ 20: [2, 71],
+ 18: [2, 19],
+ },
{
23: [2, 1],
22: [3, 52],
@@ -1063,7 +1744,9 @@ export default class LogicsParser {
3: [3, 50],
2: [3, 51],
},
- { 28: [3, 58] },
+ {
+ 28: [3, 58],
+ },
],
goto: [
{
@@ -1096,13 +1779,35 @@ export default class LogicsParser {
49: [2, 13],
43: [2, 16],
},
- { 56: [2, 27], 55: [3, 20], 54: [2, 29] },
- { 52: [3, 32], 50: [3, 35], 49: [2, 13], 43: [2, 16] },
+ {
+ 56: [2, 27],
+ 55: [3, 20],
+ 54: [2, 29],
+ },
+ {
+ 52: [3, 32],
+ 50: [3, 35],
+ 49: [2, 13],
+ 43: [2, 16],
+ },
{},
- { 52: [3, 33], 50: [3, 35], 49: [2, 13], 43: [2, 16] },
+ {
+ 52: [3, 33],
+ 50: [3, 35],
+ 49: [2, 13],
+ 43: [2, 16],
+ },
{},
- { 52: [3, 34], 50: [3, 35], 49: [2, 13], 43: [2, 16] },
- { 48: [3, 39], 47: [2, 37] },
+ {
+ 52: [3, 34],
+ 50: [3, 35],
+ 49: [2, 13],
+ 43: [2, 16],
+ },
+ {
+ 48: [3, 39],
+ 47: [2, 37],
+ },
{
62: [2, 40],
61: [2, 4],
@@ -1189,22 +1894,122 @@ export default class LogicsParser {
43: [2, 16],
},
{},
- { 57: [2, 48], 53: [2, 9], 52: [3, 31], 51: [2, 11], 50: [3, 35], 49: [2, 13], 43: [2, 16] },
- { 57: [2, 49], 53: [2, 9], 52: [3, 31], 51: [2, 11], 50: [3, 35], 49: [2, 13], 43: [2, 16] },
- { 57: [2, 50], 53: [2, 9], 52: [3, 31], 51: [2, 11], 50: [3, 35], 49: [2, 13], 43: [2, 16] },
- { 57: [2, 51], 53: [2, 9], 52: [3, 31], 51: [2, 11], 50: [3, 35], 49: [2, 13], 43: [2, 16] },
- { 57: [2, 52], 53: [2, 9], 52: [3, 31], 51: [2, 11], 50: [3, 35], 49: [2, 13], 43: [2, 16] },
- { 57: [2, 53], 53: [2, 9], 52: [3, 31], 51: [2, 11], 50: [3, 35], 49: [2, 13], 43: [2, 16] },
- { 57: [2, 54], 53: [2, 9], 52: [3, 31], 51: [2, 11], 50: [3, 35], 49: [2, 13], 43: [2, 16] },
- { 56: [2, 27], 55: [3, 19] },
- { 53: [2, 55], 52: [3, 31], 51: [2, 11], 50: [3, 35], 49: [2, 13], 43: [2, 16] },
- { 53: [2, 56], 52: [3, 31], 51: [2, 11], 50: [3, 35], 49: [2, 13], 43: [2, 16] },
- { 52: [3, 25], 50: [3, 35], 49: [2, 13], 43: [2, 16] },
- { 52: [3, 26], 50: [3, 35], 49: [2, 13], 43: [2, 16] },
- { 52: [3, 27], 50: [3, 35], 49: [2, 13], 43: [2, 16] },
- { 52: [3, 28], 50: [3, 35], 49: [2, 13], 43: [2, 16] },
- { 52: [3, 30], 50: [3, 35], 49: [2, 13], 43: [2, 16] },
- { 48: [3, 38] },
+ {
+ 57: [2, 48],
+ 53: [2, 9],
+ 52: [3, 31],
+ 51: [2, 11],
+ 50: [3, 35],
+ 49: [2, 13],
+ 43: [2, 16],
+ },
+ {
+ 57: [2, 49],
+ 53: [2, 9],
+ 52: [3, 31],
+ 51: [2, 11],
+ 50: [3, 35],
+ 49: [2, 13],
+ 43: [2, 16],
+ },
+ {
+ 57: [2, 50],
+ 53: [2, 9],
+ 52: [3, 31],
+ 51: [2, 11],
+ 50: [3, 35],
+ 49: [2, 13],
+ 43: [2, 16],
+ },
+ {
+ 57: [2, 51],
+ 53: [2, 9],
+ 52: [3, 31],
+ 51: [2, 11],
+ 50: [3, 35],
+ 49: [2, 13],
+ 43: [2, 16],
+ },
+ {
+ 57: [2, 52],
+ 53: [2, 9],
+ 52: [3, 31],
+ 51: [2, 11],
+ 50: [3, 35],
+ 49: [2, 13],
+ 43: [2, 16],
+ },
+ {
+ 57: [2, 53],
+ 53: [2, 9],
+ 52: [3, 31],
+ 51: [2, 11],
+ 50: [3, 35],
+ 49: [2, 13],
+ 43: [2, 16],
+ },
+ {
+ 57: [2, 54],
+ 53: [2, 9],
+ 52: [3, 31],
+ 51: [2, 11],
+ 50: [3, 35],
+ 49: [2, 13],
+ 43: [2, 16],
+ },
+ {
+ 56: [2, 27],
+ 55: [3, 19],
+ },
+ {
+ 53: [2, 55],
+ 52: [3, 31],
+ 51: [2, 11],
+ 50: [3, 35],
+ 49: [2, 13],
+ 43: [2, 16],
+ },
+ {
+ 53: [2, 56],
+ 52: [3, 31],
+ 51: [2, 11],
+ 50: [3, 35],
+ 49: [2, 13],
+ 43: [2, 16],
+ },
+ {
+ 52: [3, 25],
+ 50: [3, 35],
+ 49: [2, 13],
+ 43: [2, 16],
+ },
+ {
+ 52: [3, 26],
+ 50: [3, 35],
+ 49: [2, 13],
+ 43: [2, 16],
+ },
+ {
+ 52: [3, 27],
+ 50: [3, 35],
+ 49: [2, 13],
+ 43: [2, 16],
+ },
+ {
+ 52: [3, 28],
+ 50: [3, 35],
+ 49: [2, 13],
+ 43: [2, 16],
+ },
+ {
+ 52: [3, 30],
+ 50: [3, 35],
+ 49: [2, 13],
+ 43: [2, 16],
+ },
+ {
+ 48: [3, 38],
+ },
{
62: [2, 57],
61: [2, 4],
@@ -1224,11 +2029,21 @@ export default class LogicsParser {
{},
{},
{},
- { 39: [3, 70] },
+ {
+ 39: [3, 70],
+ },
{},
{},
{},
- { 57: [2, 63], 53: [2, 9], 52: [3, 31], 51: [2, 11], 50: [3, 35], 49: [2, 13], 43: [2, 16] },
+ {
+ 57: [2, 63],
+ 53: [2, 9],
+ 52: [3, 31],
+ 51: [2, 11],
+ 50: [3, 35],
+ 49: [2, 13],
+ 43: [2, 16],
+ },
{},
{},
{},
@@ -1300,7 +2115,9 @@ export default class LogicsParser {
44: [2, 67],
43: [2, 16],
},
- { 39: [2, 68] },
+ {
+ 39: [2, 68],
+ },
{},
{},
{},
@@ -1317,7 +2134,10 @@ export default class LogicsParser {
49: [2, 13],
43: [2, 16],
},
- { 42: [3, 60], 41: [2, 72] },
+ {
+ 42: [3, 60],
+ 41: [2, 72],
+ },
{
62: [3, 59],
61: [2, 4],
diff --git a/logics-py/logics/parser.py b/logics-py/logics/parser.py
index 6c7283b..b1a2102 100644
--- a/logics-py/logics/parser.py
+++ b/logics-py/logics/parser.py
@@ -1,13 +1,17 @@
-#!/usr/bin/python
+#!/usr/bin/env python
# -*- coding: utf-8 -*-
-
-# Parser module generated by unicc from logics.par.
+#
+# This parser module was generated by unicc from logics.par.
# DO NOT EDIT THIS FILE MANUALLY, IT WILL GO AWAY!
+#
class LogicsNode(object):
"""
This is an AST node.
+
+ Objects of this class are only created when the parser makes
+ use of the AST node syntax.
"""
def __init__(self, emit=None, match=None, children=None):
@@ -32,6 +36,7 @@ def dump(self, level=0):
class LogicsParseException(Exception):
"""
Exception to be raised on a parse error.
+ TODO: This might be replaced by SyntaxError builtin.
"""
def __init__(self, row, col, txt=None):
@@ -52,17 +57,26 @@ def __init__(self, row, col, txt=None):
self.expecting = expecting
-class LogicsParserToken(object):
+class _LogicsToken(object):
+ """
+ Only used internally;
+ Represents a token on the stack.
+ """
+
state = 0
line = 0
column = 0
-
node = None
-
value = None
-class LogicsParserControlBlock(object):
+class _LogicsControlBlock(object):
+ """
+ Only used internally;
+ Represents the current parser state, and allows to
+ run multiple parser threads within one LogicsParser.
+ """
+
def __init__(self, input):
# Stack
self.stack = []
@@ -100,6 +114,11 @@ def __init__(self, input):
class LogicsParser(object):
+ """
+ Implements a LALR-Parser for @@name.
+ Call LogicsParser.parse() to start parsing a given string.
+ """
+
# Actions
_ERROR = 0
_REDUCE = 1
@@ -2102,8 +2121,6 @@ class LogicsParser(object):
),
)
- # Parsing actions
-
# Parsing algorithm
def _get_act(self, pcb):
@@ -2260,10 +2277,10 @@ def parse(self, s=None):
except NameError:
s = input(">")
- pcb = LogicsParserControlBlock(s)
+ pcb = _LogicsControlBlock(s)
pcb.act = self._SHIFT
- pcb.tos = LogicsParserToken()
+ pcb.tos = _LogicsToken()
pcb.stack.append(pcb.tos)
while True:
@@ -2304,7 +2321,6 @@ def parse(self, s=None):
if self._productions[pcb.idx][1]:
# print("%s = %s" % (self._productions[pcb.idx][0], self._productions[pcb.idx][1]))
node = LogicsNode(self._productions[pcb.idx][1], children=cnodes)
-
else:
node = None
@@ -2321,7 +2337,7 @@ def parse(self, s=None):
self._get_go(pcb)
- pcb.tos = LogicsParserToken()
+ pcb.tos = _LogicsToken()
pcb.stack.append(pcb.tos)
pcb.tos.symbol = self._symbols[pcb.lhs]
@@ -2353,7 +2369,7 @@ def parse(self, s=None):
if pcb.act & self._SHIFT:
# print("SHIFT", pcb.sym, self._symbols[pcb.sym])
- pcb.tos = LogicsParserToken()
+ pcb.tos = _LogicsToken()
pcb.stack.append(pcb.tos)
# Execute scanner actions, if existing.
diff --git a/logics.par b/logics.par
index 5b628c8..fe99007 100644
--- a/logics.par
+++ b/logics.par
@@ -1,9 +1,9 @@
// Logics: A Python-like evaluation language
-// Grammar requires unicc >= 1.8, use Makefile for building.
+// This grammar requires unicc >= 1.9 to compile, use the Makefile for building.
-#!mode scanner;
-#prefix "Logics";
-#whitespaces @whitespace ;
+%!mode scanner;
+%prefix "Logics";
+%whitespaces @whitespace;
@whitespace ' \r\n\t'+
| "#" !'\n'* '\n'