|
|
|
@ -41,18 +41,18 @@ var utils = require("../../utils"),
|
|
|
|
|
* currPos = stack.pop();
|
|
|
|
|
* stack.push(value);
|
|
|
|
|
*
|
|
|
|
|
* [8] APPEND
|
|
|
|
|
* [7] APPEND
|
|
|
|
|
*
|
|
|
|
|
* value = stack.pop();
|
|
|
|
|
* array = stack.pop();
|
|
|
|
|
* array.push(value);
|
|
|
|
|
* stack.push(array);
|
|
|
|
|
*
|
|
|
|
|
* [9] WRAP n
|
|
|
|
|
* [8] WRAP n
|
|
|
|
|
*
|
|
|
|
|
* stack.push(stack.pop(n));
|
|
|
|
|
*
|
|
|
|
|
* [10] TEXT
|
|
|
|
|
* [9] TEXT
|
|
|
|
|
*
|
|
|
|
|
* stack.pop();
|
|
|
|
|
* stack.push(input.substring(stack.top(), currPos));
|
|
|
|
@ -60,7 +60,7 @@ var utils = require("../../utils"),
|
|
|
|
|
* Conditions and Loops
|
|
|
|
|
* --------------------
|
|
|
|
|
*
|
|
|
|
|
* [11] IF t, f
|
|
|
|
|
* [10] IF t, f
|
|
|
|
|
*
|
|
|
|
|
* if (stack.top()) {
|
|
|
|
|
* interpret(ip + 3, ip + 3 + t);
|
|
|
|
@ -68,7 +68,7 @@ var utils = require("../../utils"),
|
|
|
|
|
* interpret(ip + 3 + t, ip + 3 + t + f);
|
|
|
|
|
* }
|
|
|
|
|
*
|
|
|
|
|
* [12] IF_ERROR t, f
|
|
|
|
|
* [11] IF_ERROR t, f
|
|
|
|
|
*
|
|
|
|
|
* if (stack.top() === null) {
|
|
|
|
|
* interpret(ip + 3, ip + 3 + t);
|
|
|
|
@ -76,7 +76,7 @@ var utils = require("../../utils"),
|
|
|
|
|
* interpret(ip + 3 + t, ip + 3 + t + f);
|
|
|
|
|
* }
|
|
|
|
|
*
|
|
|
|
|
* [13] IF_NOT_ERROR t, f
|
|
|
|
|
* [12] IF_NOT_ERROR t, f
|
|
|
|
|
*
|
|
|
|
|
* if (stack.top() !== null) {
|
|
|
|
|
* interpret(ip + 3, ip + 3 + t);
|
|
|
|
@ -84,7 +84,7 @@ var utils = require("../../utils"),
|
|
|
|
|
* interpret(ip + 3 + t, ip + 3 + t + f);
|
|
|
|
|
* }
|
|
|
|
|
*
|
|
|
|
|
* [14] WHILE_NOT_ERROR b
|
|
|
|
|
* [13] WHILE_NOT_ERROR b
|
|
|
|
|
*
|
|
|
|
|
* while(stack.top() !== null) {
|
|
|
|
|
* interpret(ip + 2, ip + 2 + b);
|
|
|
|
@ -93,7 +93,7 @@ var utils = require("../../utils"),
|
|
|
|
|
* Matching
|
|
|
|
|
* --------
|
|
|
|
|
*
|
|
|
|
|
* [15] MATCH_ANY a, f, ...
|
|
|
|
|
* [14] MATCH_ANY a, f, ...
|
|
|
|
|
*
|
|
|
|
|
* if (input.length > currPos) {
|
|
|
|
|
* interpret(ip + 3, ip + 3 + a);
|
|
|
|
@ -101,7 +101,7 @@ var utils = require("../../utils"),
|
|
|
|
|
* interpret(ip + 3 + a, ip + 3 + a + f);
|
|
|
|
|
* }
|
|
|
|
|
*
|
|
|
|
|
* [16] MATCH_STRING s, a, f, ...
|
|
|
|
|
* [15] MATCH_STRING s, a, f, ...
|
|
|
|
|
*
|
|
|
|
|
* if (input.substr(currPos, consts[s].length) === consts[s]) {
|
|
|
|
|
* interpret(ip + 4, ip + 4 + a);
|
|
|
|
@ -109,7 +109,7 @@ var utils = require("../../utils"),
|
|
|
|
|
* interpret(ip + 4 + a, ip + 4 + a + f);
|
|
|
|
|
* }
|
|
|
|
|
*
|
|
|
|
|
* [17] MATCH_STRING_IC s, a, f, ...
|
|
|
|
|
* [16] MATCH_STRING_IC s, a, f, ...
|
|
|
|
|
*
|
|
|
|
|
* if (input.substr(currPos, consts[s].length).toLowerCase() === consts[s]) {
|
|
|
|
|
* interpret(ip + 4, ip + 4 + a);
|
|
|
|
@ -117,7 +117,7 @@ var utils = require("../../utils"),
|
|
|
|
|
* interpret(ip + 4 + a, ip + 4 + a + f);
|
|
|
|
|
* }
|
|
|
|
|
*
|
|
|
|
|
* [18] MATCH_REGEXP r, a, f, ...
|
|
|
|
|
* [17] MATCH_REGEXP r, a, f, ...
|
|
|
|
|
*
|
|
|
|
|
* if (consts[r].test(input.charAt(currPos))) {
|
|
|
|
|
* interpret(ip + 4, ip + 4 + a);
|
|
|
|
@ -125,17 +125,17 @@ var utils = require("../../utils"),
|
|
|
|
|
* interpret(ip + 4 + a, ip + 4 + a + f);
|
|
|
|
|
* }
|
|
|
|
|
*
|
|
|
|
|
* [19] ACCEPT_N n
|
|
|
|
|
* [18] ACCEPT_N n
|
|
|
|
|
*
|
|
|
|
|
* stack.push(input.substring(currPos, n));
|
|
|
|
|
* currPos += n;
|
|
|
|
|
*
|
|
|
|
|
* [20] ACCEPT_STRING s
|
|
|
|
|
* [19] ACCEPT_STRING s
|
|
|
|
|
*
|
|
|
|
|
* stack.push(consts[s]);
|
|
|
|
|
* currPos += consts[s].length;
|
|
|
|
|
*
|
|
|
|
|
* [21] FAIL e
|
|
|
|
|
* [20] FAIL e
|
|
|
|
|
*
|
|
|
|
|
* stack.push(null);
|
|
|
|
|
* fail(consts[e]);
|
|
|
|
@ -143,15 +143,15 @@ var utils = require("../../utils"),
|
|
|
|
|
* Calls
|
|
|
|
|
* -----
|
|
|
|
|
*
|
|
|
|
|
* [22] REPORT_SAVED_POS p
|
|
|
|
|
* [21] REPORT_SAVED_POS p
|
|
|
|
|
*
|
|
|
|
|
* reportedPos = stack[p];
|
|
|
|
|
*
|
|
|
|
|
* [23] REPORT_CURR_POS
|
|
|
|
|
* [22] REPORT_CURR_POS
|
|
|
|
|
*
|
|
|
|
|
* reportedPos = currPos;
|
|
|
|
|
*
|
|
|
|
|
* [25] CALL f, n, pc, p1, p2, ..., pN
|
|
|
|
|
* [23] CALL f, n, pc, p1, p2, ..., pN
|
|
|
|
|
*
|
|
|
|
|
* value = consts[f](stack[p1], ..., stack[pN]);
|
|
|
|
|
* stack.pop(n);
|
|
|
|
@ -160,18 +160,18 @@ var utils = require("../../utils"),
|
|
|
|
|
* Rules
|
|
|
|
|
* -----
|
|
|
|
|
*
|
|
|
|
|
* [26] RULE r
|
|
|
|
|
* [24] RULE r
|
|
|
|
|
*
|
|
|
|
|
* stack.push(parseRule(r));
|
|
|
|
|
*
|
|
|
|
|
* Failure Reporting
|
|
|
|
|
* -----------------
|
|
|
|
|
*
|
|
|
|
|
* [27] SILENT_FAILS_ON
|
|
|
|
|
* [25] SILENT_FAILS_ON
|
|
|
|
|
*
|
|
|
|
|
* silentFails++;
|
|
|
|
|
*
|
|
|
|
|
* [28] SILENT_FAILS_OFF
|
|
|
|
|
* [26] SILENT_FAILS_OFF
|
|
|
|
|
*
|
|
|
|
|
* silentFails--;
|
|
|
|
|
*/
|
|
|
|
|