diff --git a/build.js b/build.js old mode 100644 new mode 100755 index d0302e2..8f82ffb --- a/build.js +++ b/build.js @@ -1,3 +1,5 @@ +#!/usr/bin/env node + var fs = require('fs') var pegjs = require('pegjs') var overrideAction = require('pegjs-override-action') @@ -6,10 +8,12 @@ var input = __dirname + '/grammar.pegjs' var output = __dirname + '/parser.js' var overrides = __dirname + '/overrides.js' +var trace = false; if (require.main === module) { if (process.argv[2] == '-w') { watch() } else { + if (process.argv[2] == '-t') trace = true; console.log(getSource()) } } @@ -19,6 +23,7 @@ function getSource () { var grammar = fs.readFileSync(input, 'utf8') var parserSource = pegjs.buildParser(grammar, { output: "source", + trace: trace, allowedStartRules: [ 'script', 'command', diff --git a/grammar.pegjs b/grammar.pegjs index 0de4795..c099b6d 100644 --- a/grammar.pegjs +++ b/grammar.pegjs @@ -7,7 +7,8 @@ statementList space* last:controlOperator? spaceNL* statement - = statement:( subshell + = statement:(arithmeticStatement + / subshell / bashExtensions / command / variableAssignment @@ -20,6 +21,9 @@ statement chainedStatement = operator:('&&' / '||') spaceNL* statement:statement +arithmeticStatement "an arithmetic statement" + = "((" space* expression:arithmetic space* "))" + subshell "a subshell" = "(" space* statements:statementList space* ")" @@ -85,6 +89,7 @@ concatenation "concatenation of strings and/or variables" / bareword / environmentVariable / variableSubstitution + / arithmeticSubstitution / commandSubstitution / singleQuote / doubleQuote @@ -123,7 +128,8 @@ doubleQuoteMeta = '"' / '$' / '`' expandsInQuotes - = commandSubstitution + = arithmeticSubstitution + / commandSubstitution / environmentVariable / variableSubstitution @@ -140,6 +146,9 @@ commandSubstitution parenCommandSubstitution = '$(' commands:statementList ')' +arithmeticSubstitution + = '$((' expression:arithmetic '))' + backQuote = '`' input:backQuoteChar+ '`' @@ -200,8 +209,109 @@ keyword ) ( spaceNL+ / EOF ) +// http://www.gnu.org/software/bash/manual/html_node/Shell-Arithmetic.html +arithmetic "an arithmetic expression" + = expression:aComma { return expression } + +aComma "a sequence of arithmetic expressions" + = head:aAssign tail:( spaceNL* "," spaceNL* expr:aAssign { return expr } )* + +aAssign "an arithmetic assignment" + = left:aCond spaceNL* operator:( "=" !"=" / "*=" / "/=" / "%=" / "+=" / "-=" / "<<=" / ">>=" / "&=" / "^=" / "|=" ) spaceNL* right:aAssign + / other:aCond + +aCond "an arithmetic conditional expression" + = test:aLogicalOr spaceNL* "?" spaceNL* consequent:aAssign spaceNL* ":" spaceNL* alternate:aAssign + / other:aLogicalOr + +aLogicalOr "an arithmetic logical or" + = head:aLogicalAnd tail:(spaceNL* op:"||" spaceNL* node:aLogicalAnd { return {op: op, node: node} })* + +aLogicalAnd "an arithmetic logical and" + = head:aBitwiseOr tail:(spaceNL* op:"&&" spaceNL* node:aBitwiseOr { return {op: op, node: node} })* + +aBitwiseOr + = head:aBitwiseXor tail:(spaceNL* op:"|" ![|=] spaceNL* node:aBitwiseXor { return {op: op, node: node} })* + +aBitwiseXor + = head:aBitwiseAnd tail:(spaceNL* op:"^" !"=" spaceNL* node:aBitwiseAnd { return {op: op, node: node} })* + +aBitwiseAnd + = head:aEquality tail:(spaceNL* op:"&" ![&=] spaceNL* node:aEquality { return {op: op, node: node} })* + +aEquality + = head:aComparison tail:(spaceNL* op:( "==" / "!=" ) spaceNL* node:aComparison { return {op: op, node: node} })* + +aComparison + = head:aBitwiseShift tail:(spaceNL* op:( "<=" / ">=" / (v:"<" !"<" { return v }) / (v:">" !">" { return v }) ) spaceNL* node:aBitwiseShift { return {op: op, node: node} })* + +aBitwiseShift + = head:aAddSubtract tail:(spaceNL* op:( "<<" / ">>" ) !"=" spaceNL* node:aAddSubtract { return {op: op, node: node} })* + +aAddSubtract + = head:aMultDivModulo tail:(spaceNL* op:( "+" / "-" ) !"=" spaceNL* node:aMultDivModulo { return {op: op, node: node} })* + +aMultDivModulo + = head:aExponent tail:(spaceNL* op:( (v:"*" !"*" { return v }) / "/" / "%") !"=" spaceNL* node:aExponent { return {op: op, node: node} })* + +aExponent + = head:aNegation tail:(spaceNL* op:"**" spaceNL* node:aNegation { return {op: op, node: node} })* + +aNegation + = operator:( "!" / "~" ) spaceNL* argument:aNegation + / other:aUnary + +aUnary + = operator:( (op:"+" ![+=]) { return op } / (op:"-" ![-=]) { return op } ) spaceNL* argument:aUnary + / other:aPreIncDec + +aPreIncDec + = operator:( "++" / "--" ) spaceNL* argument:aPreIncDec + / other:aPostIncDec + +aPostIncDec + = argument:aMemberExpr operators:(spaceNL* op:( "++" / "--" ) { return op })+ + / other:aMemberExpr + + +aMemberExpr + = head:aParenExpr tail:(spaceNL* "[" property:arithmetic "]" { return property })* + +aParenExpr + = '(' spaceNL* value:arithmetic spaceNL* ')' { return value } + / other:aLiteral { return other } + +aBareword "arithmetic variable" + = !'#' name:aBarewordChar+ + +aBarewordChar + = '\\' chr:aBarewordMeta { return chr } + / !aBarewordMeta chr:. { return chr } + +aBarewordMeta = [$"';&<>\n()\[\]*?|`:+^\- ] + +aConcatenation "concatenation of strings and/or variables" + = pieces:( aBareword + / environmentVariable + / variableSubstitution + / arithmeticSubstitution + / commandSubstitution + / singleQuote + / doubleQuote + )+ + +aLiteral + = val:aNumber { return val } + / val:aConcatenation { return val } + +aNumber + = "0" [xX] digits:[0-9a-fA-Z]+ + / base:[0-9]+ "#" digits:[0-9a-zA-Z]+ + / "0" digits:[0-7]+ + / digits:[0-9]+ + continuationStart - = &( keyword / '"' / "'" / '`' / "$(" / "${" ) .* + = &( keyword / '"' / "'" / '`' / "$(" / "$((" / "${" ) .* EOF = !. diff --git a/overrides.js b/overrides.js index 3c024ee..c4707da 100644 --- a/overrides.js +++ b/overrides.js @@ -67,6 +67,14 @@ exports.initializer = [ type: 'concatenation', pieces: result } + }, + // create a nested tree from a list of same-precedence operators + function buildTree(head, tail, createNode) { + var result = head; + for (var i = 0, l = tail.length; i < l; i++) { + result = createNode(result, tail[i]); + } + return result; } ].join('\n') @@ -97,6 +105,13 @@ rules.statementList = function (first, tail, last) { } } +rules.arithmeticStatement = function (expression) { + return { + type: 'arithmeticStatement', + expression: expression, + } +} + rules.subshell = function (statements) { return { type: 'subshell', @@ -267,6 +282,13 @@ rules.parenCommandSubstitution = function (commands) { } } +rules.arithmeticSubstitution = function (expression) { + return { + type: 'arithmeticSubstitution', + expression: expression + }; +} + rules.backQuote = function (input) { return { type: 'commandSubstitution', commands: parse(input.join('')) } } @@ -304,3 +326,140 @@ rules.redirectFd = function (fd, op, filename) { filename: filename } } + +rules.aBareword = function (name) { + // TODO: check if array + return {type: 'variable', name: name.join('')} +} + +rules.aConcatenation = function (pieces) { + // TODO: if it's an array, nest it + return flattenConcatenation(pieces) +} + +rules.aNumber = [ + function (digits) { + return {type: 'number', value: parseInt(digits.join(''), 16)} + }, + function (base, digits) { + return {type: 'number', value: parseInt(digits.join(''), parseInt(base.join(''), 10))} + }, + function (digits) { + return {type: 'number', value: parseInt(digits.join(''), 8)} + }, + function (digits) { + return {type: 'number', value: parseInt(digits.join(''), 10)} + } +] + +rules.aComma = function (head, tail) { + if (tail.length) { + return { + type: 'arithmeticSequence', + expressions: [head].concat(tail) + } + } + return head +} + +function other(other) { return other } + +rules.aCond = [ + function (test, consequent, alternate) { + return { + type: 'arithmeticConditional', + test: test, + consequent: consequent, + alternate: alternate + } + }, other +] + +rules.aAssign = [ + function (left, operator, right) { + return { + type: 'arithmeticAssignment', + left: left, + operator: operator, + right: right + } + }, other +] + +rules.aLogicalOr = +rules.aLogicalAnd = +function (head, tail) { + return buildTree(head, tail, function (child, current) { + return { + type: 'arithmeticLogical', + operator: current.op, + left: child, + right: current.node + } + }); +} + +rules.aBitwiseOr = +rules.aBitwiseXor = +rules.aBitwiseAnd = +rules.aEquality = +rules.aComparison = +rules.aBitwiseShift = +rules.aAddSubtract = +rules.aMultDivModulo = +rules.aExponent = +function (head, tail) { + return buildTree(head, tail, function (child, current) { + return { + type: 'arithmeticBinary', + operator: current.op, + left: child, + right: current.node + } + }); +} + +rules.aNegation = rules.aUnary = +[ + function (operator, argument) { + return { + type: 'arithmeticUnary', + operator: operator, + argument: argument + } + }, other +] + +rules.aPreIncDec = [ + function (operator, argument) { + return { + type: 'arithmeticUpdate', + operator: operator, + argument: argument, + prefix: true + } + }, other +] + +rules.aPostIncDec = [ + function (argument, operators) { + return buildTree(argument, operators, function (node, operator) { + return { + type: 'arithmeticUpdate', + operator: operator, + argument: node, + prefix: false + } + }); + }, other +] + +rules.aMemberExpr = function (head, tail) { + return buildTree(head, tail, function (child, current) { + return { + type: 'arithmeticMemberExpression', + array: child, + property: current + } + }); +} diff --git a/package.json b/package.json index 734be20..b9db322 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ }, "scripts": { "test": "tape tests/*.js", - "watch": "npm run prepublish && node build.js -w", + "watch": "npm run prepublish && echo watching... && node build.js -w", "prepublish": "node build.js > parser.js" }, "testling": { @@ -35,10 +35,10 @@ } }, "devDependencies": { + "markdown-code-blocks": "0.0.1", "pegjs": "~0.9.0", "pegjs-override-action": "0.2.3", "tape": "^4.5.1", - "markdown-code-blocks": "0.0.1", "xtend": "~2.1.1" }, "repository": { diff --git a/parser.js b/parser.js index 48f4f91..4377d37 100644 --- a/parser.js +++ b/parser.js @@ -92,19 +92,30 @@ var parser=(function() { peg$c7 = function(operator, statement) { return [operator, statement] }, - peg$c8 = { type: "other", description: "a subshell" }, - peg$c9 = "(", - peg$c10 = { type: "literal", value: "(", description: "\"(\"" }, - peg$c11 = ")", - peg$c12 = { type: "literal", value: ")", description: "\")\"" }, - peg$c13 = function(statements) { + peg$c8 = { type: "other", description: "an arithmetic statement" }, + peg$c9 = "((", + peg$c10 = { type: "literal", value: "((", description: "\"((\"" }, + peg$c11 = "))", + peg$c12 = { type: "literal", value: "))", description: "\"))\"" }, + peg$c13 = function(expression) { + return { + type: 'arithmeticStatement', + expression: expression, + } + }, + peg$c14 = { type: "other", description: "a subshell" }, + peg$c15 = "(", + peg$c16 = { type: "literal", value: "(", description: "\"(\"" }, + peg$c17 = ")", + peg$c18 = { type: "literal", value: ")", description: "\")\"" }, + peg$c19 = function(statements) { return { type: 'subshell', statements: statements, } }, - peg$c14 = { type: "other", description: "a single command" }, - peg$c15 = function(pre, name, post, pipe) { + peg$c20 = { type: "other", description: "a single command" }, + peg$c21 = function(pre, name, post, pipe) { var command = { type: 'command', command: name, @@ -135,19 +146,19 @@ var parser=(function() { return command }, - peg$c16 = function(test) { + peg$c22 = function(test) { return test }, - peg$c17 = { type: "other", description: "an if/elif/else statement" }, - peg$c18 = "if", - peg$c19 = { type: "literal", value: "if", description: "\"if\"" }, - peg$c20 = "then", - peg$c21 = { type: "literal", value: "then", description: "\"then\"" }, - peg$c22 = "else", - peg$c23 = { type: "literal", value: "else", description: "\"else\"" }, - peg$c24 = "fi", - peg$c25 = { type: "literal", value: "fi", description: "\"fi\"" }, - peg$c26 = function(test, body, elifBlocks, elseBody) { + peg$c23 = { type: "other", description: "an if/elif/else statement" }, + peg$c24 = "if", + peg$c25 = { type: "literal", value: "if", description: "\"if\"" }, + peg$c26 = "then", + peg$c27 = { type: "literal", value: "then", description: "\"then\"" }, + peg$c28 = "else", + peg$c29 = { type: "literal", value: "else", description: "\"else\"" }, + peg$c30 = "fi", + peg$c31 = { type: "literal", value: "fi", description: "\"fi\"" }, + peg$c32 = function(test, body, elifBlocks, elseBody) { return { type: 'ifElse', test: test, @@ -156,41 +167,41 @@ var parser=(function() { elseBody: elseBody ? elseBody[1] : null, } }, - peg$c27 = "elif", - peg$c28 = { type: "literal", value: "elif", description: "\"elif\"" }, - peg$c29 = function(test, body) { + peg$c33 = "elif", + peg$c34 = { type: "literal", value: "elif", description: "\"elif\"" }, + peg$c35 = function(test, body) { return { type: 'ifElse', test: test, body: body } }, - peg$c30 = { type: "other", description: "a while/until loop" }, - peg$c31 = "while", - peg$c32 = { type: "literal", value: "while", description: "\"while\"" }, - peg$c33 = "until", - peg$c34 = { type: "literal", value: "until", description: "\"until\"" }, - peg$c35 = "do", - peg$c36 = { type: "literal", value: "do", description: "\"do\"" }, - peg$c37 = "done", - peg$c38 = { type: "literal", value: "done", description: "\"done\"" }, - peg$c39 = function(kind, test, body) { + peg$c36 = { type: "other", description: "a while/until loop" }, + peg$c37 = "while", + peg$c38 = { type: "literal", value: "while", description: "\"while\"" }, + peg$c39 = "until", + peg$c40 = { type: "literal", value: "until", description: "\"until\"" }, + peg$c41 = "do", + peg$c42 = { type: "literal", value: "do", description: "\"do\"" }, + peg$c43 = "done", + peg$c44 = { type: "literal", value: "done", description: "\"done\"" }, + peg$c45 = function(kind, test, body) { return { type: kind + 'Loop', test: test, body: body } }, - peg$c40 = { type: "other", description: "a for loop" }, - peg$c41 = "for", - peg$c42 = { type: "literal", value: "for", description: "\"for\"" }, - peg$c43 = "in", - peg$c44 = { type: "literal", value: "in", description: "\"in\"" }, - peg$c45 = ";", - peg$c46 = { type: "literal", value: ";", description: "\";\"" }, - peg$c47 = "\n", - peg$c48 = { type: "literal", value: "\n", description: "\"\\n\"" }, - peg$c49 = function(loopVar, subjects, body) { + peg$c46 = { type: "other", description: "a for loop" }, + peg$c47 = "for", + peg$c48 = { type: "literal", value: "for", description: "\"for\"" }, + peg$c49 = "in", + peg$c50 = { type: "literal", value: "in", description: "\"in\"" }, + peg$c51 = ";", + peg$c52 = { type: "literal", value: ";", description: "\";\"" }, + peg$c53 = "\n", + peg$c54 = { type: "literal", value: "\n", description: "\"\\n\"" }, + peg$c55 = function(loopVar, subjects, body) { return { type: 'forLoop', loopVariable: loopVar, @@ -198,136 +209,144 @@ var parser=(function() { body: body } }, - peg$c50 = { type: "other", description: "time builtin" }, - peg$c51 = "time", - peg$c52 = { type: "literal", value: "time", description: "\"time\"" }, - peg$c53 = "-", - peg$c54 = { type: "literal", value: "-", description: "\"-\"" }, - peg$c55 = /^[a-z]/, - peg$c56 = { type: "class", value: "[a-z]", description: "[a-z]" }, - peg$c57 = function(flags, statements) { + peg$c56 = { type: "other", description: "time builtin" }, + peg$c57 = "time", + peg$c58 = { type: "literal", value: "time", description: "\"time\"" }, + peg$c59 = "-", + peg$c60 = { type: "literal", value: "-", description: "\"-\"" }, + peg$c61 = /^[a-z]/, + peg$c62 = { type: "class", value: "[a-z]", description: "[a-z]" }, + peg$c63 = function(flags, statements) { return { type: 'time', flags: flags, command: statements } }, - peg$c58 = { type: "other", description: "declare builtin" }, - peg$c59 = "declare", - peg$c60 = { type: "literal", value: "declare", description: "\"declare\"" }, - peg$c61 = "typeset", - peg$c62 = { type: "literal", value: "typeset", description: "\"typeset\"" }, - peg$c63 = /^[^\n]/, - peg$c64 = { type: "class", value: "[^\\n]", description: "[^\\n]" }, - peg$c65 = { type: "other", description: "a variable assignment" }, - peg$c66 = "=", - peg$c67 = { type: "literal", value: "=", description: "\"=\"" }, - peg$c68 = function(name, value) { + peg$c64 = { type: "other", description: "declare builtin" }, + peg$c65 = "declare", + peg$c66 = { type: "literal", value: "declare", description: "\"declare\"" }, + peg$c67 = "typeset", + peg$c68 = { type: "literal", value: "typeset", description: "\"typeset\"" }, + peg$c69 = /^[^\n]/, + peg$c70 = { type: "class", value: "[^\\n]", description: "[^\\n]" }, + peg$c71 = { type: "other", description: "a variable assignment" }, + peg$c72 = "=", + peg$c73 = { type: "literal", value: "=", description: "\"=\"" }, + peg$c74 = function(name, value) { return {type: 'variableAssignment', name: name, value: value} }, - peg$c69 = { type: "other", description: "command name" }, - peg$c70 = function(name) { + peg$c75 = { type: "other", description: "command name" }, + peg$c76 = function(name) { return name }, - peg$c71 = "[[", - peg$c72 = { type: "literal", value: "[[", description: "\"[[\"" }, - peg$c73 = "[", - peg$c74 = { type: "literal", value: "[", description: "\"[\"" }, - peg$c75 = { type: "other", description: "command argument" }, - peg$c76 = { type: "other", description: "concatenation of strings and/or variables" }, - peg$c77 = function(pieces) { + peg$c77 = "[[", + peg$c78 = { type: "literal", value: "[[", description: "\"[[\"" }, + peg$c79 = "[", + peg$c80 = { type: "literal", value: "[", description: "\"[\"" }, + peg$c81 = { type: "other", description: "command argument" }, + peg$c82 = { type: "other", description: "concatenation of strings and/or variables" }, + peg$c83 = function(pieces) { return flattenConcatenation(pieces) }, - peg$c78 = { type: "other", description: "bareword" }, - peg$c79 = "#", - peg$c80 = { type: "literal", value: "#", description: "\"#\"" }, - peg$c81 = function(cs) { return literal(cs) }, - peg$c82 = "\\", - peg$c83 = { type: "literal", value: "\\", description: "\"\\\\\"" }, - peg$c84 = function(chr) { return chr }, - peg$c85 = { type: "any", description: "any character" }, - peg$c86 = /^[$"';&<>\n()[*?|` ]/, - peg$c87 = { type: "class", value: "[$\"';&<>\\n()\\[*?|` ]", description: "[$\"';&<>\\n()\\[*?|` ]" }, - peg$c88 = "*", - peg$c89 = { type: "literal", value: "*", description: "\"*\"" }, - peg$c90 = "?", - peg$c91 = { type: "literal", value: "?", description: "\"?\"" }, - peg$c92 = function() { + peg$c84 = { type: "other", description: "bareword" }, + peg$c85 = "#", + peg$c86 = { type: "literal", value: "#", description: "\"#\"" }, + peg$c87 = function(cs) { return literal(cs) }, + peg$c88 = "\\", + peg$c89 = { type: "literal", value: "\\", description: "\"\\\\\"" }, + peg$c90 = function(chr) { return chr }, + peg$c91 = { type: "any", description: "any character" }, + peg$c92 = /^[$"';&<>\n()[*?|` ]/, + peg$c93 = { type: "class", value: "[$\"';&<>\\n()\\[*?|` ]", description: "[$\"';&<>\\n()\\[*?|` ]" }, + peg$c94 = "*", + peg$c95 = { type: "literal", value: "*", description: "\"*\"" }, + peg$c96 = "?", + peg$c97 = { type: "literal", value: "?", description: "\"?\"" }, + peg$c98 = function() { return { type: 'glob', value: text() } }, - peg$c93 = "]", - peg$c94 = { type: "literal", value: "]", description: "\"]\"" }, - peg$c95 = "$", - peg$c96 = { type: "literal", value: "$", description: "\"$\"" }, - peg$c97 = "{", - peg$c98 = { type: "literal", value: "{", description: "\"{\"" }, - peg$c99 = "}", - peg$c100 = { type: "literal", value: "}", description: "\"}\"" }, - peg$c101 = "'", - peg$c102 = { type: "literal", value: "'", description: "\"'\"" }, - peg$c103 = /^[^']/, - peg$c104 = { type: "class", value: "[^']", description: "[^']" }, - peg$c105 = function(inner) { return literal(inner) }, - peg$c106 = "\"", - peg$c107 = { type: "literal", value: "\"", description: "\"\\\"\"" }, - peg$c108 = function(contents) { + peg$c99 = "]", + peg$c100 = { type: "literal", value: "]", description: "\"]\"" }, + peg$c101 = "$", + peg$c102 = { type: "literal", value: "$", description: "\"$\"" }, + peg$c103 = "{", + peg$c104 = { type: "literal", value: "{", description: "\"{\"" }, + peg$c105 = "}", + peg$c106 = { type: "literal", value: "}", description: "\"}\"" }, + peg$c107 = "'", + peg$c108 = { type: "literal", value: "'", description: "\"'\"" }, + peg$c109 = /^[^']/, + peg$c110 = { type: "class", value: "[^']", description: "[^']" }, + peg$c111 = function(inner) { return literal(inner) }, + peg$c112 = "\"", + peg$c113 = { type: "literal", value: "\"", description: "\"\\\"\"" }, + peg$c114 = function(contents) { var pieces = contents.map(function (it) { return isArray(it) ? literal(it) : it }) return flattenConcatenation(pieces) }, - peg$c109 = "\\\\", - peg$c110 = { type: "literal", value: "\\\\", description: "\"\\\\\\\\\"" }, - peg$c111 = function() { return '\\' }, - peg$c112 = "`", - peg$c113 = { type: "literal", value: "`", description: "\"`\"" }, - peg$c114 = function(name) { + peg$c115 = "\\\\", + peg$c116 = { type: "literal", value: "\\\\", description: "\"\\\\\\\\\"" }, + peg$c117 = function() { return '\\' }, + peg$c118 = "`", + peg$c119 = { type: "literal", value: "`", description: "\"`\"" }, + peg$c120 = function(name) { return {type: 'variable', name: name} }, - peg$c115 = /^[a-zA-Z0-9_]/, - peg$c116 = { type: "class", value: "[a-zA-Z0-9_]", description: "[a-zA-Z0-9_]" }, - peg$c117 = function() { return text() }, - peg$c118 = "${", - peg$c119 = { type: "literal", value: "${", description: "\"${\"" }, - peg$c120 = /^[^}]/, - peg$c121 = { type: "class", value: "[^}]", description: "[^}]" }, - peg$c122 = function(expr) { + peg$c121 = /^[a-zA-Z0-9_]/, + peg$c122 = { type: "class", value: "[a-zA-Z0-9_]", description: "[a-zA-Z0-9_]" }, + peg$c123 = function() { return text() }, + peg$c124 = "${", + peg$c125 = { type: "literal", value: "${", description: "\"${\"" }, + peg$c126 = /^[^}]/, + peg$c127 = { type: "class", value: "[^}]", description: "[^}]" }, + peg$c128 = function(expr) { return { type: 'variableSubstitution', expression: join(expr), // TODO subParser } }, - peg$c123 = "$(", - peg$c124 = { type: "literal", value: "$(", description: "\"$(\"" }, - peg$c125 = function(commands) { + peg$c129 = "$(", + peg$c130 = { type: "literal", value: "$(", description: "\"$(\"" }, + peg$c131 = function(commands) { return { type: 'commandSubstitution', commands: commands } }, - peg$c126 = function(input) { + peg$c132 = "$((", + peg$c133 = { type: "literal", value: "$((", description: "\"$((\"" }, + peg$c134 = function(expression) { + return { + type: 'arithmeticSubstitution', + expression: expression + }; + }, + peg$c135 = function(input) { return { type: 'commandSubstitution', commands: parse(input.join('')) } }, - peg$c127 = "\\`", - peg$c128 = { type: "literal", value: "\\`", description: "\"\\\\`\"" }, - peg$c129 = function() { return '`' }, - peg$c130 = /^[<>]/, - peg$c131 = { type: "class", value: "[<>]", description: "[<>]" }, - peg$c132 = function(rw, commands) { + peg$c136 = "\\`", + peg$c137 = { type: "literal", value: "\\`", description: "\"\\\\`\"" }, + peg$c138 = function() { return '`' }, + peg$c139 = /^[<>]/, + peg$c140 = { type: "class", value: "[<>]", description: "[<>]" }, + peg$c141 = function(rw, commands) { return { type: 'processSubstitution', readWrite: rw, commands: commands, } }, - peg$c133 = "<&", - peg$c134 = { type: "literal", value: "<&", description: "\"<&\"" }, - peg$c135 = ">&", - peg$c136 = { type: "literal", value: ">&", description: "\">&\"" }, - peg$c137 = function(fd, op, dest) { + peg$c142 = "<&", + peg$c143 = { type: "literal", value: "<&", description: "\"<&\"" }, + peg$c144 = ">&", + peg$c145 = { type: "literal", value: ">&", description: "\">&\"" }, + peg$c146 = function(fd, op, dest) { if (fd == null) fd = op[0] == '<' ? 0 : 1; return { type: 'moveFd', @@ -336,7 +355,7 @@ var parser=(function() { dest: dest } }, - peg$c138 = function(src, op, dest) { + peg$c147 = function(src, op, dest) { if (src == null) src = op[0] == '<' ? 0 : 1; return { type: 'duplicateFd', @@ -345,7 +364,7 @@ var parser=(function() { destFd: dest, } }, - peg$c139 = function(fd, op, filename) { + peg$c148 = function(fd, op, filename) { if (fd == null) fd = op[0] == '<' ? 0 : 1; return { type: 'redirectFd', @@ -354,41 +373,229 @@ var parser=(function() { filename: filename } }, - peg$c140 = ">|", - peg$c141 = { type: "literal", value: ">|", description: "\">|\"" }, - peg$c142 = ">>", - peg$c143 = { type: "literal", value: ">>", description: "\">>\"" }, - peg$c144 = "&>>", - peg$c145 = { type: "literal", value: "&>>", description: "\"&>>\"" }, - peg$c146 = "&>", - peg$c147 = { type: "literal", value: "&>", description: "\"&>\"" }, - peg$c148 = "<", - peg$c149 = { type: "literal", value: "<", description: "\"<\"" }, - peg$c150 = ">", - peg$c151 = { type: "literal", value: ">", description: "\">\"" }, - peg$c152 = /^[0-9]/, - peg$c153 = { type: "class", value: "[0-9]", description: "[0-9]" }, - peg$c154 = function(digits) { return parseInt(join(digits), 10) }, - peg$c155 = "&", - peg$c156 = { type: "literal", value: "&", description: "\"&\"" }, - peg$c157 = function(op) { + peg$c149 = ">|", + peg$c150 = { type: "literal", value: ">|", description: "\">|\"" }, + peg$c151 = ">>", + peg$c152 = { type: "literal", value: ">>", description: "\">>\"" }, + peg$c153 = "&>>", + peg$c154 = { type: "literal", value: "&>>", description: "\"&>>\"" }, + peg$c155 = "&>", + peg$c156 = { type: "literal", value: "&>", description: "\"&>\"" }, + peg$c157 = "<", + peg$c158 = { type: "literal", value: "<", description: "\"<\"" }, + peg$c159 = ">", + peg$c160 = { type: "literal", value: ">", description: "\">\"" }, + peg$c161 = /^[0-9]/, + peg$c162 = { type: "class", value: "[0-9]", description: "[0-9]" }, + peg$c163 = function(digits) { return parseInt(join(digits), 10) }, + peg$c164 = "&", + peg$c165 = { type: "literal", value: "&", description: "\"&\"" }, + peg$c166 = function(op) { return op == '\n' ? ';' : op }, - peg$c158 = "|", - peg$c159 = { type: "literal", value: "|", description: "\"|\"" }, - peg$c160 = function(command) { + peg$c167 = "|", + peg$c168 = { type: "literal", value: "|", description: "\"|\"" }, + peg$c169 = function(command) { return {type: 'pipe', command: command} }, - peg$c161 = { type: "other", description: "whitespace" }, - peg$c162 = " ", - peg$c163 = { type: "literal", value: " ", description: "\" \"" }, - peg$c164 = "\t", - peg$c165 = { type: "literal", value: "\t", description: "\"\\t\"" }, - peg$c166 = { type: "other", description: "a comment" }, - peg$c167 = "case", - peg$c168 = { type: "literal", value: "case", description: "\"case\"" }, - peg$c169 = "esac", - peg$c170 = { type: "literal", value: "esac", description: "\"esac\"" }, + peg$c170 = { type: "other", description: "whitespace" }, + peg$c171 = " ", + peg$c172 = { type: "literal", value: " ", description: "\" \"" }, + peg$c173 = "\t", + peg$c174 = { type: "literal", value: "\t", description: "\"\\t\"" }, + peg$c175 = { type: "other", description: "a comment" }, + peg$c176 = "case", + peg$c177 = { type: "literal", value: "case", description: "\"case\"" }, + peg$c178 = "esac", + peg$c179 = { type: "literal", value: "esac", description: "\"esac\"" }, + peg$c180 = { type: "other", description: "an arithmetic expression" }, + peg$c181 = function(expression) { return expression }, + peg$c182 = { type: "other", description: "a sequence of arithmetic expressions" }, + peg$c183 = ",", + peg$c184 = { type: "literal", value: ",", description: "\",\"" }, + peg$c185 = function(head, expr) { return expr }, + peg$c186 = function(head, tail) { + if (tail.length) { + return { + type: 'arithmeticSequence', + expressions: [head].concat(tail) + } + } + return head + }, + peg$c187 = { type: "other", description: "an arithmetic assignment" }, + peg$c188 = "*=", + peg$c189 = { type: "literal", value: "*=", description: "\"*=\"" }, + peg$c190 = "/=", + peg$c191 = { type: "literal", value: "/=", description: "\"/=\"" }, + peg$c192 = "%=", + peg$c193 = { type: "literal", value: "%=", description: "\"%=\"" }, + peg$c194 = "+=", + peg$c195 = { type: "literal", value: "+=", description: "\"+=\"" }, + peg$c196 = "-=", + peg$c197 = { type: "literal", value: "-=", description: "\"-=\"" }, + peg$c198 = "<<=", + peg$c199 = { type: "literal", value: "<<=", description: "\"<<=\"" }, + peg$c200 = ">>=", + peg$c201 = { type: "literal", value: ">>=", description: "\">>=\"" }, + peg$c202 = "&=", + peg$c203 = { type: "literal", value: "&=", description: "\"&=\"" }, + peg$c204 = "^=", + peg$c205 = { type: "literal", value: "^=", description: "\"^=\"" }, + peg$c206 = "|=", + peg$c207 = { type: "literal", value: "|=", description: "\"|=\"" }, + peg$c208 = function(left, operator, right) { + return { + type: 'arithmeticAssignment', + left: left, + operator: operator, + right: right + } + }, + peg$c209 = function(other) { return other }, + peg$c210 = { type: "other", description: "an arithmetic conditional expression" }, + peg$c211 = ":", + peg$c212 = { type: "literal", value: ":", description: "\":\"" }, + peg$c213 = function(test, consequent, alternate) { + return { + type: 'arithmeticConditional', + test: test, + consequent: consequent, + alternate: alternate + } + }, + peg$c214 = { type: "other", description: "an arithmetic logical or" }, + peg$c215 = function(head, op, node) { return {op: op, node: node} }, + peg$c216 = function(head, tail) { + return buildTree(head, tail, function (child, current) { + return { + type: 'arithmeticLogical', + operator: current.op, + left: child, + right: current.node + } + }); + }, + peg$c217 = { type: "other", description: "an arithmetic logical and" }, + peg$c218 = /^[|=]/, + peg$c219 = { type: "class", value: "[|=]", description: "[|=]" }, + peg$c220 = function(head, tail) { + return buildTree(head, tail, function (child, current) { + return { + type: 'arithmeticBinary', + operator: current.op, + left: child, + right: current.node + } + }); + }, + peg$c221 = "^", + peg$c222 = { type: "literal", value: "^", description: "\"^\"" }, + peg$c223 = /^[&=]/, + peg$c224 = { type: "class", value: "[&=]", description: "[&=]" }, + peg$c225 = "==", + peg$c226 = { type: "literal", value: "==", description: "\"==\"" }, + peg$c227 = "!=", + peg$c228 = { type: "literal", value: "!=", description: "\"!=\"" }, + peg$c229 = "<=", + peg$c230 = { type: "literal", value: "<=", description: "\"<=\"" }, + peg$c231 = ">=", + peg$c232 = { type: "literal", value: ">=", description: "\">=\"" }, + peg$c233 = function(head, v) { return v }, + peg$c234 = "<<", + peg$c235 = { type: "literal", value: "<<", description: "\"<<\"" }, + peg$c236 = "+", + peg$c237 = { type: "literal", value: "+", description: "\"+\"" }, + peg$c238 = "/", + peg$c239 = { type: "literal", value: "/", description: "\"/\"" }, + peg$c240 = "%", + peg$c241 = { type: "literal", value: "%", description: "\"%\"" }, + peg$c242 = "**", + peg$c243 = { type: "literal", value: "**", description: "\"**\"" }, + peg$c244 = "!", + peg$c245 = { type: "literal", value: "!", description: "\"!\"" }, + peg$c246 = "~", + peg$c247 = { type: "literal", value: "~", description: "\"~\"" }, + peg$c248 = function(operator, argument) { + return { + type: 'arithmeticUnary', + operator: operator, + argument: argument + } + }, + peg$c249 = /^[+=]/, + peg$c250 = { type: "class", value: "[+=]", description: "[+=]" }, + peg$c251 = function(op) { return op }, + peg$c252 = /^[\-=]/, + peg$c253 = { type: "class", value: "[-=]", description: "[-=]" }, + peg$c254 = "++", + peg$c255 = { type: "literal", value: "++", description: "\"++\"" }, + peg$c256 = "--", + peg$c257 = { type: "literal", value: "--", description: "\"--\"" }, + peg$c258 = function(operator, argument) { + return { + type: 'arithmeticUpdate', + operator: operator, + argument: argument, + prefix: true + } + }, + peg$c259 = function(argument, op) { return op }, + peg$c260 = function(argument, operators) { + return buildTree(argument, operators, function (node, operator) { + return { + type: 'arithmeticUpdate', + operator: operator, + argument: node, + prefix: false + } + }); + }, + peg$c261 = function(head, property) { return property }, + peg$c262 = function(head, tail) { + return buildTree(head, tail, function (child, current) { + return { + type: 'arithmeticMemberExpression', + array: child, + property: current + } + }); + }, + peg$c263 = function(value) { return value }, + peg$c264 = { type: "other", description: "arithmetic variable" }, + peg$c265 = function(name) { + // TODO: check if array + return {type: 'variable', name: name.join('')} + }, + peg$c266 = /^[$"';&<>\n()[\]*?|`:+\^\- ]/, + peg$c267 = { type: "class", value: "[$\"';&<>\\n()\\[\\]*?|`:+^\\- ]", description: "[$\"';&<>\\n()\\[\\]*?|`:+^\\- ]" }, + peg$c268 = function(pieces) { + // TODO: if it's an array, nest it + return flattenConcatenation(pieces) + }, + peg$c269 = function(val) { return val }, + peg$c270 = "0", + peg$c271 = { type: "literal", value: "0", description: "\"0\"" }, + peg$c272 = /^[xX]/, + peg$c273 = { type: "class", value: "[xX]", description: "[xX]" }, + peg$c274 = /^[0-9a-fA-Z]/, + peg$c275 = { type: "class", value: "[0-9a-fA-Z]", description: "[0-9a-fA-Z]" }, + peg$c276 = function(digits) { + return {type: 'number', value: parseInt(digits.join(''), 16)} + }, + peg$c277 = /^[0-9a-zA-Z]/, + peg$c278 = { type: "class", value: "[0-9a-zA-Z]", description: "[0-9a-zA-Z]" }, + peg$c279 = function(base, digits) { + return {type: 'number', value: parseInt(digits.join(''), parseInt(base.join(''), 10))} + }, + peg$c280 = /^[0-7]/, + peg$c281 = { type: "class", value: "[0-7]", description: "[0-7]" }, + peg$c282 = function(digits) { + return {type: 'number', value: parseInt(digits.join(''), 8)} + }, + peg$c283 = function(digits) { + return {type: 'number', value: parseInt(digits.join(''), 10)} + }, peg$currPos = 0, peg$savedPos = 0, @@ -719,19 +926,22 @@ var parser=(function() { var s0, s1, s2, s3, s4; s0 = peg$currPos; - s1 = peg$parsesubshell(); + s1 = peg$parsearithmeticStatement(); if (s1 === peg$FAILED) { - s1 = peg$parsebashExtensions(); + s1 = peg$parsesubshell(); if (s1 === peg$FAILED) { - s1 = peg$parsecommand(); + s1 = peg$parsebashExtensions(); if (s1 === peg$FAILED) { - s1 = peg$parsevariableAssignment(); + s1 = peg$parsecommand(); if (s1 === peg$FAILED) { - s1 = peg$parseifBlock(); + s1 = peg$parsevariableAssignment(); if (s1 === peg$FAILED) { - s1 = peg$parseconditionalLoop(); + s1 = peg$parseifBlock(); if (s1 === peg$FAILED) { - s1 = peg$parseforLoop(); + s1 = peg$parseconditionalLoop(); + if (s1 === peg$FAILED) { + s1 = peg$parseforLoop(); + } } } } @@ -827,14 +1037,14 @@ var parser=(function() { return s0; } - function peg$parsesubshell() { + function peg$parsearithmeticStatement() { var s0, s1, s2, s3, s4, s5; peg$silentFails++; s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 40) { + if (input.substr(peg$currPos, 2) === peg$c9) { s1 = peg$c9; - peg$currPos++; + peg$currPos += 2; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c10); } @@ -847,7 +1057,7 @@ var parser=(function() { s3 = peg$parsespace(); } if (s2 !== peg$FAILED) { - s3 = peg$parsestatementList(); + s3 = peg$parsearithmetic(); if (s3 !== peg$FAILED) { s4 = []; s5 = peg$parsespace(); @@ -856,9 +1066,9 @@ var parser=(function() { s5 = peg$parsespace(); } if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 41) { + if (input.substr(peg$currPos, 2) === peg$c11) { s5 = peg$c11; - peg$currPos++; + peg$currPos += 2; } else { s5 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c12); } @@ -896,6 +1106,75 @@ var parser=(function() { return s0; } + function peg$parsesubshell() { + var s0, s1, s2, s3, s4, s5; + + peg$silentFails++; + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 40) { + s1 = peg$c15; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c16); } + } + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parsespace(); + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parsespace(); + } + if (s2 !== peg$FAILED) { + s3 = peg$parsestatementList(); + if (s3 !== peg$FAILED) { + s4 = []; + s5 = peg$parsespace(); + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = peg$parsespace(); + } + if (s4 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 41) { + s5 = peg$c17; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c18); } + } + if (s5 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c19(s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c14); } + } + + return s0; + } + function peg$parsecommand() { var s0, s1, s2, s3, s4, s5, s6; @@ -1049,7 +1328,7 @@ var parser=(function() { } if (s4 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c15(s1, s2, s3, s4); + s1 = peg$c21(s1, s2, s3, s4); s0 = s1; } else { peg$currPos = s0; @@ -1070,7 +1349,7 @@ var parser=(function() { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c14); } + if (peg$silentFails === 0) { peg$fail(peg$c20); } } return s0; @@ -1083,7 +1362,7 @@ var parser=(function() { s1 = peg$parsescript(); if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c16(s1); + s1 = peg$c22(s1); } s0 = s1; @@ -1095,12 +1374,12 @@ var parser=(function() { peg$silentFails++; s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c18) { - s1 = peg$c18; + if (input.substr(peg$currPos, 2) === peg$c24) { + s1 = peg$c24; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c19); } + if (peg$silentFails === 0) { peg$fail(peg$c25); } } if (s1 !== peg$FAILED) { s2 = []; @@ -1116,12 +1395,12 @@ var parser=(function() { if (s2 !== peg$FAILED) { s3 = peg$parsecondition(); if (s3 !== peg$FAILED) { - if (input.substr(peg$currPos, 4) === peg$c20) { - s4 = peg$c20; + if (input.substr(peg$currPos, 4) === peg$c26) { + s4 = peg$c26; peg$currPos += 4; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c21); } + if (peg$silentFails === 0) { peg$fail(peg$c27); } } if (s4 !== peg$FAILED) { s5 = []; @@ -1145,12 +1424,12 @@ var parser=(function() { } if (s7 !== peg$FAILED) { s8 = peg$currPos; - if (input.substr(peg$currPos, 4) === peg$c22) { - s9 = peg$c22; + if (input.substr(peg$currPos, 4) === peg$c28) { + s9 = peg$c28; peg$currPos += 4; } else { s9 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c23); } + if (peg$silentFails === 0) { peg$fail(peg$c29); } } if (s9 !== peg$FAILED) { s10 = peg$parsescript(); @@ -1169,16 +1448,16 @@ var parser=(function() { s8 = null; } if (s8 !== peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c24) { - s9 = peg$c24; + if (input.substr(peg$currPos, 2) === peg$c30) { + s9 = peg$c30; peg$currPos += 2; } else { s9 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c25); } + if (peg$silentFails === 0) { peg$fail(peg$c31); } } if (s9 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c26(s3, s6, s7, s8); + s1 = peg$c32(s3, s6, s7, s8); s0 = s1; } else { peg$currPos = s0; @@ -1219,7 +1498,7 @@ var parser=(function() { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c17); } + if (peg$silentFails === 0) { peg$fail(peg$c23); } } return s0; @@ -1229,12 +1508,12 @@ var parser=(function() { var s0, s1, s2, s3, s4, s5, s6; s0 = peg$currPos; - if (input.substr(peg$currPos, 4) === peg$c27) { - s1 = peg$c27; + if (input.substr(peg$currPos, 4) === peg$c33) { + s1 = peg$c33; peg$currPos += 4; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c28); } + if (peg$silentFails === 0) { peg$fail(peg$c34); } } if (s1 !== peg$FAILED) { s2 = []; @@ -1250,12 +1529,12 @@ var parser=(function() { if (s2 !== peg$FAILED) { s3 = peg$parsecondition(); if (s3 !== peg$FAILED) { - if (input.substr(peg$currPos, 4) === peg$c20) { - s4 = peg$c20; + if (input.substr(peg$currPos, 4) === peg$c26) { + s4 = peg$c26; peg$currPos += 4; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c21); } + if (peg$silentFails === 0) { peg$fail(peg$c27); } } if (s4 !== peg$FAILED) { s5 = []; @@ -1272,7 +1551,7 @@ var parser=(function() { s6 = peg$parsescript(); if (s6 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c29(s3, s6); + s1 = peg$c35(s3, s6); s0 = s1; } else { peg$currPos = s0; @@ -1307,20 +1586,20 @@ var parser=(function() { peg$silentFails++; s0 = peg$currPos; - if (input.substr(peg$currPos, 5) === peg$c31) { - s1 = peg$c31; + if (input.substr(peg$currPos, 5) === peg$c37) { + s1 = peg$c37; peg$currPos += 5; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c32); } + if (peg$silentFails === 0) { peg$fail(peg$c38); } } if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 5) === peg$c33) { - s1 = peg$c33; + if (input.substr(peg$currPos, 5) === peg$c39) { + s1 = peg$c39; peg$currPos += 5; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c34); } + if (peg$silentFails === 0) { peg$fail(peg$c40); } } } if (s1 !== peg$FAILED) { @@ -1337,12 +1616,12 @@ var parser=(function() { if (s2 !== peg$FAILED) { s3 = peg$parsecondition(); if (s3 !== peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c35) { - s4 = peg$c35; + if (input.substr(peg$currPos, 2) === peg$c41) { + s4 = peg$c41; peg$currPos += 2; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c36); } + if (peg$silentFails === 0) { peg$fail(peg$c42); } } if (s4 !== peg$FAILED) { s5 = []; @@ -1358,16 +1637,16 @@ var parser=(function() { if (s5 !== peg$FAILED) { s6 = peg$parsescript(); if (s6 !== peg$FAILED) { - if (input.substr(peg$currPos, 4) === peg$c37) { - s7 = peg$c37; + if (input.substr(peg$currPos, 4) === peg$c43) { + s7 = peg$c43; peg$currPos += 4; } else { s7 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c38); } + if (peg$silentFails === 0) { peg$fail(peg$c44); } } if (s7 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c39(s1, s3, s6); + s1 = peg$c45(s1, s3, s6); s0 = s1; } else { peg$currPos = s0; @@ -1400,7 +1679,7 @@ var parser=(function() { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c30); } + if (peg$silentFails === 0) { peg$fail(peg$c36); } } return s0; @@ -1411,12 +1690,12 @@ var parser=(function() { peg$silentFails++; s0 = peg$currPos; - if (input.substr(peg$currPos, 3) === peg$c41) { - s1 = peg$c41; + if (input.substr(peg$currPos, 3) === peg$c47) { + s1 = peg$c47; peg$currPos += 3; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c42); } + if (peg$silentFails === 0) { peg$fail(peg$c48); } } if (s1 !== peg$FAILED) { s2 = []; @@ -1444,12 +1723,12 @@ var parser=(function() { } if (s4 !== peg$FAILED) { s5 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c43) { - s6 = peg$c43; + if (input.substr(peg$currPos, 2) === peg$c49) { + s6 = peg$c49; peg$currPos += 2; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c44); } + if (peg$silentFails === 0) { peg$fail(peg$c50); } } if (s6 !== peg$FAILED) { s7 = []; @@ -1527,19 +1806,19 @@ var parser=(function() { } if (s6 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 59) { - s7 = peg$c45; + s7 = peg$c51; peg$currPos++; } else { s7 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c46); } + if (peg$silentFails === 0) { peg$fail(peg$c52); } } if (s7 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 10) { - s7 = peg$c47; + s7 = peg$c53; peg$currPos++; } else { s7 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c48); } + if (peg$silentFails === 0) { peg$fail(peg$c54); } } } if (s7 !== peg$FAILED) { @@ -1550,12 +1829,12 @@ var parser=(function() { s9 = peg$parsespaceNL(); } if (s8 !== peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c35) { - s9 = peg$c35; + if (input.substr(peg$currPos, 2) === peg$c41) { + s9 = peg$c41; peg$currPos += 2; } else { s9 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c36); } + if (peg$silentFails === 0) { peg$fail(peg$c42); } } if (s9 !== peg$FAILED) { s10 = []; @@ -1578,16 +1857,16 @@ var parser=(function() { s13 = peg$parsespaceNL(); } if (s12 !== peg$FAILED) { - if (input.substr(peg$currPos, 4) === peg$c37) { - s13 = peg$c37; + if (input.substr(peg$currPos, 4) === peg$c43) { + s13 = peg$c43; peg$currPos += 4; } else { s13 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c38); } + if (peg$silentFails === 0) { peg$fail(peg$c44); } } if (s13 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c49(s3, s5, s11); + s1 = peg$c55(s3, s5, s11); s0 = s1; } else { peg$currPos = s0; @@ -1644,7 +1923,7 @@ var parser=(function() { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c40); } + if (peg$silentFails === 0) { peg$fail(peg$c46); } } return s0; @@ -1666,12 +1945,12 @@ var parser=(function() { peg$silentFails++; s0 = peg$currPos; - if (input.substr(peg$currPos, 4) === peg$c51) { - s1 = peg$c51; + if (input.substr(peg$currPos, 4) === peg$c57) { + s1 = peg$c57; peg$currPos += 4; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c52); } + if (peg$silentFails === 0) { peg$fail(peg$c58); } } if (s1 !== peg$FAILED) { s2 = []; @@ -1688,30 +1967,30 @@ var parser=(function() { s3 = []; s4 = peg$currPos; if (input.charCodeAt(peg$currPos) === 45) { - s5 = peg$c53; + s5 = peg$c59; peg$currPos++; } else { s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c54); } + if (peg$silentFails === 0) { peg$fail(peg$c60); } } if (s5 !== peg$FAILED) { s6 = []; - if (peg$c55.test(input.charAt(peg$currPos))) { + if (peg$c61.test(input.charAt(peg$currPos))) { s7 = input.charAt(peg$currPos); peg$currPos++; } else { s7 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c56); } + if (peg$silentFails === 0) { peg$fail(peg$c62); } } if (s7 !== peg$FAILED) { while (s7 !== peg$FAILED) { s6.push(s7); - if (peg$c55.test(input.charAt(peg$currPos))) { + if (peg$c61.test(input.charAt(peg$currPos))) { s7 = input.charAt(peg$currPos); peg$currPos++; } else { s7 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c56); } + if (peg$silentFails === 0) { peg$fail(peg$c62); } } } } else { @@ -1747,30 +2026,30 @@ var parser=(function() { s3.push(s4); s4 = peg$currPos; if (input.charCodeAt(peg$currPos) === 45) { - s5 = peg$c53; + s5 = peg$c59; peg$currPos++; } else { s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c54); } + if (peg$silentFails === 0) { peg$fail(peg$c60); } } if (s5 !== peg$FAILED) { s6 = []; - if (peg$c55.test(input.charAt(peg$currPos))) { + if (peg$c61.test(input.charAt(peg$currPos))) { s7 = input.charAt(peg$currPos); peg$currPos++; } else { s7 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c56); } + if (peg$silentFails === 0) { peg$fail(peg$c62); } } if (s7 !== peg$FAILED) { while (s7 !== peg$FAILED) { s6.push(s7); - if (peg$c55.test(input.charAt(peg$currPos))) { + if (peg$c61.test(input.charAt(peg$currPos))) { s7 = input.charAt(peg$currPos); peg$currPos++; } else { s7 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c56); } + if (peg$silentFails === 0) { peg$fail(peg$c62); } } } } else { @@ -1807,7 +2086,7 @@ var parser=(function() { s4 = peg$parsestatementList(); if (s4 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c57(s3, s4); + s1 = peg$c63(s3, s4); s0 = s1; } else { peg$currPos = s0; @@ -1828,7 +2107,7 @@ var parser=(function() { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c50); } + if (peg$silentFails === 0) { peg$fail(peg$c56); } } return s0; @@ -1839,40 +2118,40 @@ var parser=(function() { peg$silentFails++; s0 = peg$currPos; - if (input.substr(peg$currPos, 7) === peg$c59) { - s1 = peg$c59; + if (input.substr(peg$currPos, 7) === peg$c65) { + s1 = peg$c65; peg$currPos += 7; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c60); } + if (peg$silentFails === 0) { peg$fail(peg$c66); } } if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 7) === peg$c61) { - s1 = peg$c61; + if (input.substr(peg$currPos, 7) === peg$c67) { + s1 = peg$c67; peg$currPos += 7; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c62); } + if (peg$silentFails === 0) { peg$fail(peg$c68); } } } if (s1 !== peg$FAILED) { s2 = []; - if (peg$c63.test(input.charAt(peg$currPos))) { + if (peg$c69.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c64); } + if (peg$silentFails === 0) { peg$fail(peg$c70); } } if (s3 !== peg$FAILED) { while (s3 !== peg$FAILED) { s2.push(s3); - if (peg$c63.test(input.charAt(peg$currPos))) { + if (peg$c69.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c64); } + if (peg$silentFails === 0) { peg$fail(peg$c70); } } } } else { @@ -1880,19 +2159,19 @@ var parser=(function() { } if (s2 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 59) { - s3 = peg$c45; + s3 = peg$c51; peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c46); } + if (peg$silentFails === 0) { peg$fail(peg$c52); } } if (s3 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 10) { - s3 = peg$c47; + s3 = peg$c53; peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c48); } + if (peg$silentFails === 0) { peg$fail(peg$c54); } } } if (s3 !== peg$FAILED) { @@ -1913,7 +2192,7 @@ var parser=(function() { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c58); } + if (peg$silentFails === 0) { peg$fail(peg$c64); } } return s0; @@ -1927,11 +2206,11 @@ var parser=(function() { s1 = peg$parsewritableVariableName(); if (s1 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 61) { - s2 = peg$c66; + s2 = peg$c72; peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c67); } + if (peg$silentFails === 0) { peg$fail(peg$c73); } } if (s2 !== peg$FAILED) { s3 = peg$parseargument(); @@ -1940,7 +2219,7 @@ var parser=(function() { } if (s3 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c68(s1, s3); + s1 = peg$c74(s1, s3); s0 = s1; } else { peg$currPos = s0; @@ -1957,7 +2236,7 @@ var parser=(function() { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c65); } + if (peg$silentFails === 0) { peg$fail(peg$c71); } } return s0; @@ -2007,7 +2286,7 @@ var parser=(function() { } if (s4 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c70(s4); + s1 = peg$c76(s4); s0 = s1; } else { peg$currPos = s0; @@ -2028,7 +2307,7 @@ var parser=(function() { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c69); } + if (peg$silentFails === 0) { peg$fail(peg$c75); } } return s0; @@ -2037,20 +2316,20 @@ var parser=(function() { function peg$parsebuiltinCommandName() { var s0; - if (input.substr(peg$currPos, 2) === peg$c71) { - s0 = peg$c71; + if (input.substr(peg$currPos, 2) === peg$c77) { + s0 = peg$c77; peg$currPos += 2; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c72); } + if (peg$silentFails === 0) { peg$fail(peg$c78); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 91) { - s0 = peg$c73; + s0 = peg$c79; peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c74); } + if (peg$silentFails === 0) { peg$fail(peg$c80); } } } @@ -2068,7 +2347,7 @@ var parser=(function() { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c75); } + if (peg$silentFails === 0) { peg$fail(peg$c81); } } return s0; @@ -2088,11 +2367,14 @@ var parser=(function() { if (s2 === peg$FAILED) { s2 = peg$parsevariableSubstitution(); if (s2 === peg$FAILED) { - s2 = peg$parsecommandSubstitution(); + s2 = peg$parsearithmeticSubstitution(); if (s2 === peg$FAILED) { - s2 = peg$parsesingleQuote(); + s2 = peg$parsecommandSubstitution(); if (s2 === peg$FAILED) { - s2 = peg$parsedoubleQuote(); + s2 = peg$parsesingleQuote(); + if (s2 === peg$FAILED) { + s2 = peg$parsedoubleQuote(); + } } } } @@ -2110,11 +2392,14 @@ var parser=(function() { if (s2 === peg$FAILED) { s2 = peg$parsevariableSubstitution(); if (s2 === peg$FAILED) { - s2 = peg$parsecommandSubstitution(); + s2 = peg$parsearithmeticSubstitution(); if (s2 === peg$FAILED) { - s2 = peg$parsesingleQuote(); + s2 = peg$parsecommandSubstitution(); if (s2 === peg$FAILED) { - s2 = peg$parsedoubleQuote(); + s2 = peg$parsesingleQuote(); + if (s2 === peg$FAILED) { + s2 = peg$parsedoubleQuote(); + } } } } @@ -2127,13 +2412,13 @@ var parser=(function() { } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c77(s1); + s1 = peg$c83(s1); } s0 = s1; peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c76); } + if (peg$silentFails === 0) { peg$fail(peg$c82); } } return s0; @@ -2147,11 +2432,11 @@ var parser=(function() { s1 = peg$currPos; peg$silentFails++; if (input.charCodeAt(peg$currPos) === 35) { - s2 = peg$c79; + s2 = peg$c85; peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c80); } + if (peg$silentFails === 0) { peg$fail(peg$c86); } } peg$silentFails--; if (s2 === peg$FAILED) { @@ -2173,7 +2458,7 @@ var parser=(function() { } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c81(s2); + s1 = peg$c87(s2); s0 = s1; } else { peg$currPos = s0; @@ -2186,7 +2471,7 @@ var parser=(function() { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c78); } + if (peg$silentFails === 0) { peg$fail(peg$c84); } } return s0; @@ -2197,17 +2482,17 @@ var parser=(function() { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 92) { - s1 = peg$c82; + s1 = peg$c88; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c83); } + if (peg$silentFails === 0) { peg$fail(peg$c89); } } if (s1 !== peg$FAILED) { s2 = peg$parsebarewordMeta(); if (s2 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c84(s2); + s1 = peg$c90(s2); s0 = s1; } else { peg$currPos = s0; @@ -2235,11 +2520,11 @@ var parser=(function() { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c85); } + if (peg$silentFails === 0) { peg$fail(peg$c91); } } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c84(s2); + s1 = peg$c90(s2); s0 = s1; } else { peg$currPos = s0; @@ -2257,12 +2542,12 @@ var parser=(function() { function peg$parsebarewordMeta() { var s0; - if (peg$c86.test(input.charAt(peg$currPos))) { + if (peg$c92.test(input.charAt(peg$currPos))) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c87); } + if (peg$silentFails === 0) { peg$fail(peg$c93); } } return s0; @@ -2281,19 +2566,19 @@ var parser=(function() { if (s1 !== peg$FAILED) { s2 = []; if (input.charCodeAt(peg$currPos) === 42) { - s3 = peg$c88; + s3 = peg$c94; peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c89); } + if (peg$silentFails === 0) { peg$fail(peg$c95); } } if (s3 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 63) { - s3 = peg$c90; + s3 = peg$c96; peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c91); } + if (peg$silentFails === 0) { peg$fail(peg$c97); } } if (s3 === peg$FAILED) { s3 = peg$parsecharacterRange(); @@ -2306,19 +2591,19 @@ var parser=(function() { while (s3 !== peg$FAILED) { s2.push(s3); if (input.charCodeAt(peg$currPos) === 42) { - s3 = peg$c88; + s3 = peg$c94; peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c89); } + if (peg$silentFails === 0) { peg$fail(peg$c95); } } if (s3 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 63) { - s3 = peg$c90; + s3 = peg$c96; peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c91); } + if (peg$silentFails === 0) { peg$fail(peg$c97); } } if (s3 === peg$FAILED) { s3 = peg$parsecharacterRange(); @@ -2340,7 +2625,7 @@ var parser=(function() { } if (s3 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c92(); + s1 = peg$c98(); s0 = s1; } else { peg$currPos = s0; @@ -2364,21 +2649,21 @@ var parser=(function() { s0 = peg$currPos; s1 = peg$currPos; if (input.charCodeAt(peg$currPos) === 91) { - s2 = peg$c73; + s2 = peg$c79; peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c74); } + if (peg$silentFails === 0) { peg$fail(peg$c80); } } if (s2 !== peg$FAILED) { s3 = peg$currPos; peg$silentFails++; if (input.charCodeAt(peg$currPos) === 45) { - s4 = peg$c53; + s4 = peg$c59; peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c54); } + if (peg$silentFails === 0) { peg$fail(peg$c60); } } peg$silentFails--; if (s4 === peg$FAILED) { @@ -2393,25 +2678,25 @@ var parser=(function() { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c85); } + if (peg$silentFails === 0) { peg$fail(peg$c91); } } if (s4 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 45) { - s5 = peg$c53; + s5 = peg$c59; peg$currPos++; } else { s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c54); } + if (peg$silentFails === 0) { peg$fail(peg$c60); } } if (s5 !== peg$FAILED) { s6 = peg$currPos; peg$silentFails++; if (input.charCodeAt(peg$currPos) === 45) { - s7 = peg$c53; + s7 = peg$c59; peg$currPos++; } else { s7 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c54); } + if (peg$silentFails === 0) { peg$fail(peg$c60); } } peg$silentFails--; if (s7 === peg$FAILED) { @@ -2426,15 +2711,15 @@ var parser=(function() { peg$currPos++; } else { s7 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c85); } + if (peg$silentFails === 0) { peg$fail(peg$c91); } } if (s7 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 93) { - s8 = peg$c93; + s8 = peg$c99; peg$currPos++; } else { s8 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c94); } + if (peg$silentFails === 0) { peg$fail(peg$c100); } } if (s8 !== peg$FAILED) { s2 = [s2, s3, s4, s5, s6, s7, s8]; @@ -2486,7 +2771,7 @@ var parser=(function() { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c85); } + if (peg$silentFails === 0) { peg$fail(peg$c91); } } if (s2 === peg$FAILED) { s2 = null; @@ -2495,11 +2780,11 @@ var parser=(function() { s3 = peg$currPos; peg$silentFails++; if (input.charCodeAt(peg$currPos) === 36) { - s4 = peg$c95; + s4 = peg$c101; peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c96); } + if (peg$silentFails === 0) { peg$fail(peg$c102); } } peg$silentFails--; if (s4 === peg$FAILED) { @@ -2521,11 +2806,11 @@ var parser=(function() { } if (s1 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 123) { - s2 = peg$c97; + s2 = peg$c103; peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c98); } + if (peg$silentFails === 0) { peg$fail(peg$c104); } } if (s2 !== peg$FAILED) { s3 = []; @@ -2540,11 +2825,11 @@ var parser=(function() { } if (s3 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 125) { - s4 = peg$c99; + s4 = peg$c105; peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c100); } + if (peg$silentFails === 0) { peg$fail(peg$c106); } } if (s4 !== peg$FAILED) { s1 = [s1, s2, s3, s4]; @@ -2574,30 +2859,30 @@ var parser=(function() { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 39) { - s1 = peg$c101; + s1 = peg$c107; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c102); } + if (peg$silentFails === 0) { peg$fail(peg$c108); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; s3 = []; - if (peg$c103.test(input.charAt(peg$currPos))) { + if (peg$c109.test(input.charAt(peg$currPos))) { s4 = input.charAt(peg$currPos); peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c104); } + if (peg$silentFails === 0) { peg$fail(peg$c110); } } while (s4 !== peg$FAILED) { s3.push(s4); - if (peg$c103.test(input.charAt(peg$currPos))) { + if (peg$c109.test(input.charAt(peg$currPos))) { s4 = input.charAt(peg$currPos); peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c104); } + if (peg$silentFails === 0) { peg$fail(peg$c110); } } } if (s3 !== peg$FAILED) { @@ -2607,15 +2892,15 @@ var parser=(function() { } if (s2 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 39) { - s3 = peg$c101; + s3 = peg$c107; peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c102); } + if (peg$silentFails === 0) { peg$fail(peg$c108); } } if (s3 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c105(s2); + s1 = peg$c111(s2); s0 = s1; } else { peg$currPos = s0; @@ -2638,11 +2923,11 @@ var parser=(function() { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 34) { - s1 = peg$c106; + s1 = peg$c112; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c107); } + if (peg$silentFails === 0) { peg$fail(peg$c113); } } if (s1 !== peg$FAILED) { s2 = []; @@ -2677,15 +2962,15 @@ var parser=(function() { } if (s2 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 34) { - s3 = peg$c106; + s3 = peg$c112; peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c107); } + if (peg$silentFails === 0) { peg$fail(peg$c113); } } if (s3 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c108(s2); + s1 = peg$c114(s2); s0 = s1; } else { peg$currPos = s0; @@ -2708,17 +2993,17 @@ var parser=(function() { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 92) { - s1 = peg$c82; + s1 = peg$c88; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c83); } + if (peg$silentFails === 0) { peg$fail(peg$c89); } } if (s1 !== peg$FAILED) { s2 = peg$parsedoubleQuoteMeta(); if (s2 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c84(s2); + s1 = peg$c90(s2); s0 = s1; } else { peg$currPos = s0; @@ -2730,16 +3015,16 @@ var parser=(function() { } if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c109) { - s1 = peg$c109; + if (input.substr(peg$currPos, 2) === peg$c115) { + s1 = peg$c115; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c110); } + if (peg$silentFails === 0) { peg$fail(peg$c116); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c111(); + s1 = peg$c117(); } s0 = s1; if (s0 === peg$FAILED) { @@ -2760,11 +3045,11 @@ var parser=(function() { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c85); } + if (peg$silentFails === 0) { peg$fail(peg$c91); } } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c84(s2); + s1 = peg$c90(s2); s0 = s1; } else { peg$currPos = s0; @@ -2784,27 +3069,27 @@ var parser=(function() { var s0; if (input.charCodeAt(peg$currPos) === 34) { - s0 = peg$c106; + s0 = peg$c112; peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c107); } + if (peg$silentFails === 0) { peg$fail(peg$c113); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 36) { - s0 = peg$c95; + s0 = peg$c101; peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c96); } + if (peg$silentFails === 0) { peg$fail(peg$c102); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 96) { - s0 = peg$c112; + s0 = peg$c118; peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c113); } + if (peg$silentFails === 0) { peg$fail(peg$c119); } } } } @@ -2815,11 +3100,14 @@ var parser=(function() { function peg$parseexpandsInQuotes() { var s0; - s0 = peg$parsecommandSubstitution(); + s0 = peg$parsearithmeticSubstitution(); if (s0 === peg$FAILED) { - s0 = peg$parseenvironmentVariable(); + s0 = peg$parsecommandSubstitution(); if (s0 === peg$FAILED) { - s0 = peg$parsevariableSubstitution(); + s0 = peg$parseenvironmentVariable(); + if (s0 === peg$FAILED) { + s0 = peg$parsevariableSubstitution(); + } } } @@ -2831,17 +3119,17 @@ var parser=(function() { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 36) { - s1 = peg$c95; + s1 = peg$c101; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c96); } + if (peg$silentFails === 0) { peg$fail(peg$c102); } } if (s1 !== peg$FAILED) { s2 = peg$parsereadableVariableName(); if (s2 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c114(s2); + s1 = peg$c120(s2); s0 = s1; } else { peg$currPos = s0; @@ -2860,22 +3148,22 @@ var parser=(function() { s0 = peg$currPos; s1 = []; - if (peg$c115.test(input.charAt(peg$currPos))) { + if (peg$c121.test(input.charAt(peg$currPos))) { s2 = input.charAt(peg$currPos); peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c116); } + if (peg$silentFails === 0) { peg$fail(peg$c122); } } if (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) { s1.push(s2); - if (peg$c115.test(input.charAt(peg$currPos))) { + if (peg$c121.test(input.charAt(peg$currPos))) { s2 = input.charAt(peg$currPos); peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c116); } + if (peg$silentFails === 0) { peg$fail(peg$c122); } } } } else { @@ -2883,7 +3171,7 @@ var parser=(function() { } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c117(); + s1 = peg$c123(); } s0 = s1; @@ -2896,11 +3184,11 @@ var parser=(function() { s0 = peg$parsewritableVariableName(); if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 63) { - s0 = peg$c90; + s0 = peg$c96; peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c91); } + if (peg$silentFails === 0) { peg$fail(peg$c97); } } } @@ -2911,43 +3199,43 @@ var parser=(function() { var s0, s1, s2, s3; s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c118) { - s1 = peg$c118; + if (input.substr(peg$currPos, 2) === peg$c124) { + s1 = peg$c124; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c119); } + if (peg$silentFails === 0) { peg$fail(peg$c125); } } if (s1 !== peg$FAILED) { s2 = []; - if (peg$c120.test(input.charAt(peg$currPos))) { + if (peg$c126.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c121); } + if (peg$silentFails === 0) { peg$fail(peg$c127); } } while (s3 !== peg$FAILED) { s2.push(s3); - if (peg$c120.test(input.charAt(peg$currPos))) { + if (peg$c126.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c121); } + if (peg$silentFails === 0) { peg$fail(peg$c127); } } } if (s2 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 125) { - s3 = peg$c99; + s3 = peg$c105; peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c100); } + if (peg$silentFails === 0) { peg$fail(peg$c106); } } if (s3 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c122(s2); + s1 = peg$c128(s2); s0 = s1; } else { peg$currPos = s0; @@ -2980,26 +3268,67 @@ var parser=(function() { var s0, s1, s2, s3; s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c123) { - s1 = peg$c123; + if (input.substr(peg$currPos, 2) === peg$c129) { + s1 = peg$c129; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c124); } + if (peg$silentFails === 0) { peg$fail(peg$c130); } } if (s1 !== peg$FAILED) { s2 = peg$parsestatementList(); if (s2 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 41) { - s3 = peg$c11; + s3 = peg$c17; peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c18); } + } + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c131(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parsearithmeticSubstitution() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 3) === peg$c132) { + s1 = peg$c132; + peg$currPos += 3; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c133); } + } + if (s1 !== peg$FAILED) { + s2 = peg$parsearithmetic(); + if (s2 !== peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c11) { + s3 = peg$c11; + peg$currPos += 2; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c12); } } if (s3 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c125(s2); + s1 = peg$c134(s2); s0 = s1; } else { peg$currPos = s0; @@ -3022,11 +3351,11 @@ var parser=(function() { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 96) { - s1 = peg$c112; + s1 = peg$c118; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c113); } + if (peg$silentFails === 0) { peg$fail(peg$c119); } } if (s1 !== peg$FAILED) { s2 = []; @@ -3041,15 +3370,15 @@ var parser=(function() { } if (s2 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 96) { - s3 = peg$c112; + s3 = peg$c118; peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c113); } + if (peg$silentFails === 0) { peg$fail(peg$c119); } } if (s3 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c126(s2); + s1 = peg$c135(s2); s0 = s1; } else { peg$currPos = s0; @@ -3071,30 +3400,30 @@ var parser=(function() { var s0, s1, s2; s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c127) { - s1 = peg$c127; + if (input.substr(peg$currPos, 2) === peg$c136) { + s1 = peg$c136; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c128); } + if (peg$silentFails === 0) { peg$fail(peg$c137); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c129(); + s1 = peg$c138(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c109) { - s1 = peg$c109; + if (input.substr(peg$currPos, 2) === peg$c115) { + s1 = peg$c115; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c110); } + if (peg$silentFails === 0) { peg$fail(peg$c116); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c111(); + s1 = peg$c117(); } s0 = s1; if (s0 === peg$FAILED) { @@ -3102,11 +3431,11 @@ var parser=(function() { s1 = peg$currPos; peg$silentFails++; if (input.charCodeAt(peg$currPos) === 96) { - s2 = peg$c112; + s2 = peg$c118; peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c113); } + if (peg$silentFails === 0) { peg$fail(peg$c119); } } peg$silentFails--; if (s2 === peg$FAILED) { @@ -3121,11 +3450,11 @@ var parser=(function() { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c85); } + if (peg$silentFails === 0) { peg$fail(peg$c91); } } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c84(s2); + s1 = peg$c90(s2); s0 = s1; } else { peg$currPos = s0; @@ -3145,34 +3474,34 @@ var parser=(function() { var s0, s1, s2, s3, s4; s0 = peg$currPos; - if (peg$c130.test(input.charAt(peg$currPos))) { + if (peg$c139.test(input.charAt(peg$currPos))) { s1 = input.charAt(peg$currPos); peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c131); } + if (peg$silentFails === 0) { peg$fail(peg$c140); } } if (s1 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 40) { - s2 = peg$c9; + s2 = peg$c15; peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c10); } + if (peg$silentFails === 0) { peg$fail(peg$c16); } } if (s2 !== peg$FAILED) { s3 = peg$parsestatementList(); if (s3 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 41) { - s4 = peg$c11; + s4 = peg$c17; peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c12); } + if (peg$silentFails === 0) { peg$fail(peg$c18); } } if (s4 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c132(s1, s3); + s1 = peg$c141(s1, s3); s0 = s1; } else { peg$currPos = s0; @@ -3217,35 +3546,35 @@ var parser=(function() { s1 = null; } if (s1 !== peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c133) { - s2 = peg$c133; + if (input.substr(peg$currPos, 2) === peg$c142) { + s2 = peg$c142; peg$currPos += 2; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c134); } + if (peg$silentFails === 0) { peg$fail(peg$c143); } } if (s2 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c135) { - s2 = peg$c135; + if (input.substr(peg$currPos, 2) === peg$c144) { + s2 = peg$c144; peg$currPos += 2; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c136); } + if (peg$silentFails === 0) { peg$fail(peg$c145); } } } if (s2 !== peg$FAILED) { s3 = peg$parsefd(); if (s3 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 45) { - s4 = peg$c53; + s4 = peg$c59; peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c54); } + if (peg$silentFails === 0) { peg$fail(peg$c60); } } if (s4 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c137(s1, s2, s3); + s1 = peg$c146(s1, s2, s3); s0 = s1; } else { peg$currPos = s0; @@ -3276,20 +3605,20 @@ var parser=(function() { s1 = null; } if (s1 !== peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c133) { - s2 = peg$c133; + if (input.substr(peg$currPos, 2) === peg$c142) { + s2 = peg$c142; peg$currPos += 2; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c134); } + if (peg$silentFails === 0) { peg$fail(peg$c143); } } if (s2 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c135) { - s2 = peg$c135; + if (input.substr(peg$currPos, 2) === peg$c144) { + s2 = peg$c144; peg$currPos += 2; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c136); } + if (peg$silentFails === 0) { peg$fail(peg$c145); } } } if (s2 !== peg$FAILED) { @@ -3303,7 +3632,7 @@ var parser=(function() { s4 = peg$parsefd(); if (s4 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c138(s1, s2, s4); + s1 = peg$c147(s1, s2, s4); s0 = s1; } else { peg$currPos = s0; @@ -3346,7 +3675,7 @@ var parser=(function() { s4 = peg$parseargument(); if (s4 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c139(s1, s2, s4); + s1 = peg$c148(s1, s2, s4); s0 = s1; } else { peg$currPos = s0; @@ -3371,52 +3700,52 @@ var parser=(function() { function peg$parseredirectionOperator() { var s0; - if (input.substr(peg$currPos, 2) === peg$c140) { - s0 = peg$c140; + if (input.substr(peg$currPos, 2) === peg$c149) { + s0 = peg$c149; peg$currPos += 2; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c141); } + if (peg$silentFails === 0) { peg$fail(peg$c150); } } if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c142) { - s0 = peg$c142; + if (input.substr(peg$currPos, 2) === peg$c151) { + s0 = peg$c151; peg$currPos += 2; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c143); } + if (peg$silentFails === 0) { peg$fail(peg$c152); } } if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 3) === peg$c144) { - s0 = peg$c144; + if (input.substr(peg$currPos, 3) === peg$c153) { + s0 = peg$c153; peg$currPos += 3; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c145); } + if (peg$silentFails === 0) { peg$fail(peg$c154); } } if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c146) { - s0 = peg$c146; + if (input.substr(peg$currPos, 2) === peg$c155) { + s0 = peg$c155; peg$currPos += 2; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c147); } + if (peg$silentFails === 0) { peg$fail(peg$c156); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 60) { - s0 = peg$c148; + s0 = peg$c157; peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c149); } + if (peg$silentFails === 0) { peg$fail(peg$c158); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 62) { - s0 = peg$c150; + s0 = peg$c159; peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c151); } + if (peg$silentFails === 0) { peg$fail(peg$c160); } } } } @@ -3432,22 +3761,22 @@ var parser=(function() { s0 = peg$currPos; s1 = []; - if (peg$c152.test(input.charAt(peg$currPos))) { + if (peg$c161.test(input.charAt(peg$currPos))) { s2 = input.charAt(peg$currPos); peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c153); } + if (peg$silentFails === 0) { peg$fail(peg$c162); } } if (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) { s1.push(s2); - if (peg$c152.test(input.charAt(peg$currPos))) { + if (peg$c161.test(input.charAt(peg$currPos))) { s2 = input.charAt(peg$currPos); peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c153); } + if (peg$silentFails === 0) { peg$fail(peg$c162); } } } } else { @@ -3455,7 +3784,7 @@ var parser=(function() { } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c154(s1); + s1 = peg$c163(s1); } s0 = s1; @@ -3474,33 +3803,33 @@ var parser=(function() { } if (s1 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 38) { - s2 = peg$c155; + s2 = peg$c164; peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c156); } + if (peg$silentFails === 0) { peg$fail(peg$c165); } } if (s2 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 59) { - s2 = peg$c45; + s2 = peg$c51; peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c46); } + if (peg$silentFails === 0) { peg$fail(peg$c52); } } if (s2 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 10) { - s2 = peg$c47; + s2 = peg$c53; peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c48); } + if (peg$silentFails === 0) { peg$fail(peg$c54); } } } } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c157(s2); + s1 = peg$c166(s2); s0 = s1; } else { peg$currPos = s0; @@ -3519,11 +3848,11 @@ var parser=(function() { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 124) { - s1 = peg$c158; + s1 = peg$c167; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c159); } + if (peg$silentFails === 0) { peg$fail(peg$c168); } } if (s1 !== peg$FAILED) { s2 = []; @@ -3536,7 +3865,7 @@ var parser=(function() { s3 = peg$parsecommand(); if (s3 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c160(s3); + s1 = peg$c169(s3); s0 = s1; } else { peg$currPos = s0; @@ -3559,25 +3888,25 @@ var parser=(function() { peg$silentFails++; if (input.charCodeAt(peg$currPos) === 32) { - s0 = peg$c162; + s0 = peg$c171; peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c163); } + if (peg$silentFails === 0) { peg$fail(peg$c172); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 9) { - s0 = peg$c164; + s0 = peg$c173; peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c165); } + if (peg$silentFails === 0) { peg$fail(peg$c174); } } } peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c161); } + if (peg$silentFails === 0) { peg$fail(peg$c170); } } return s0; @@ -3589,11 +3918,11 @@ var parser=(function() { s0 = peg$parsespace(); if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 10) { - s0 = peg$c47; + s0 = peg$c53; peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c48); } + if (peg$silentFails === 0) { peg$fail(peg$c54); } } if (s0 === peg$FAILED) { s0 = peg$parsecomment(); @@ -3609,38 +3938,38 @@ var parser=(function() { peg$silentFails++; s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 35) { - s1 = peg$c79; + s1 = peg$c85; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c80); } + if (peg$silentFails === 0) { peg$fail(peg$c86); } } if (s1 !== peg$FAILED) { s2 = []; - if (peg$c63.test(input.charAt(peg$currPos))) { + if (peg$c69.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c64); } + if (peg$silentFails === 0) { peg$fail(peg$c70); } } while (s3 !== peg$FAILED) { s2.push(s3); - if (peg$c63.test(input.charAt(peg$currPos))) { + if (peg$c69.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c64); } + if (peg$silentFails === 0) { peg$fail(peg$c70); } } } if (s2 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 10) { - s3 = peg$c47; + s3 = peg$c53; peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c48); } + if (peg$silentFails === 0) { peg$fail(peg$c54); } } if (s3 === peg$FAILED) { s3 = peg$parseEOF(); @@ -3663,7 +3992,7 @@ var parser=(function() { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c166); } + if (peg$silentFails === 0) { peg$fail(peg$c175); } } return s0; @@ -3673,108 +4002,108 @@ var parser=(function() { var s0, s1, s2, s3; s0 = peg$currPos; - if (input.substr(peg$currPos, 5) === peg$c31) { - s1 = peg$c31; + if (input.substr(peg$currPos, 5) === peg$c37) { + s1 = peg$c37; peg$currPos += 5; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c32); } + if (peg$silentFails === 0) { peg$fail(peg$c38); } } if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 5) === peg$c33) { - s1 = peg$c33; + if (input.substr(peg$currPos, 5) === peg$c39) { + s1 = peg$c39; peg$currPos += 5; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c34); } + if (peg$silentFails === 0) { peg$fail(peg$c40); } } if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 3) === peg$c41) { - s1 = peg$c41; + if (input.substr(peg$currPos, 3) === peg$c47) { + s1 = peg$c47; peg$currPos += 3; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c42); } + if (peg$silentFails === 0) { peg$fail(peg$c48); } } if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 4) === peg$c37) { - s1 = peg$c37; + if (input.substr(peg$currPos, 4) === peg$c43) { + s1 = peg$c43; peg$currPos += 4; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c38); } + if (peg$silentFails === 0) { peg$fail(peg$c44); } } if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c35) { - s1 = peg$c35; + if (input.substr(peg$currPos, 2) === peg$c41) { + s1 = peg$c41; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c36); } + if (peg$silentFails === 0) { peg$fail(peg$c42); } } if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 4) === peg$c167) { - s1 = peg$c167; + if (input.substr(peg$currPos, 4) === peg$c176) { + s1 = peg$c176; peg$currPos += 4; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c168); } + if (peg$silentFails === 0) { peg$fail(peg$c177); } } if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 4) === peg$c169) { - s1 = peg$c169; + if (input.substr(peg$currPos, 4) === peg$c178) { + s1 = peg$c178; peg$currPos += 4; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c170); } + if (peg$silentFails === 0) { peg$fail(peg$c179); } } if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c18) { - s1 = peg$c18; + if (input.substr(peg$currPos, 2) === peg$c24) { + s1 = peg$c24; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c19); } + if (peg$silentFails === 0) { peg$fail(peg$c25); } } if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 4) === peg$c20) { - s1 = peg$c20; + if (input.substr(peg$currPos, 4) === peg$c26) { + s1 = peg$c26; peg$currPos += 4; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c21); } + if (peg$silentFails === 0) { peg$fail(peg$c27); } } if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 4) === peg$c22) { - s1 = peg$c22; + if (input.substr(peg$currPos, 4) === peg$c28) { + s1 = peg$c28; peg$currPos += 4; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c23); } + if (peg$silentFails === 0) { peg$fail(peg$c29); } } if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 4) === peg$c27) { - s1 = peg$c27; + if (input.substr(peg$currPos, 4) === peg$c33) { + s1 = peg$c33; peg$currPos += 4; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c28); } + if (peg$silentFails === 0) { peg$fail(peg$c34); } } if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c24) { - s1 = peg$c24; + if (input.substr(peg$currPos, 2) === peg$c30) { + s1 = peg$c30; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c25); } + if (peg$silentFails === 0) { peg$fail(peg$c31); } } if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c71) { - s1 = peg$c71; + if (input.substr(peg$currPos, 2) === peg$c77) { + s1 = peg$c77; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c72); } + if (peg$silentFails === 0) { peg$fail(peg$c78); } } } } @@ -3817,52 +4146,3305 @@ var parser=(function() { return s0; } - function peg$parsecontinuationStart() { - var s0, s1, s2, s3; + function peg$parsearithmetic() { + var s0, s1; + peg$silentFails++; s0 = peg$currPos; - s1 = peg$currPos; + s1 = peg$parseaComma(); + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c181(s1); + } + s0 = s1; + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c180); } + } + + return s0; + } + + function peg$parseaComma() { + var s0, s1, s2, s3, s4, s5, s6, s7; + peg$silentFails++; - s2 = peg$parsekeyword(); - if (s2 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 34) { - s2 = peg$c106; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c107); } + s0 = peg$currPos; + s1 = peg$parseaAssign(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = []; + s5 = peg$parsespaceNL(); + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = peg$parsespaceNL(); } - if (s2 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 39) { - s2 = peg$c101; + if (s4 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 44) { + s5 = peg$c183; peg$currPos++; } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c102); } + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c184); } } - if (s2 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 96) { - s2 = peg$c112; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c113); } + if (s5 !== peg$FAILED) { + s6 = []; + s7 = peg$parsespaceNL(); + while (s7 !== peg$FAILED) { + s6.push(s7); + s7 = peg$parsespaceNL(); } - if (s2 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c123) { - s2 = peg$c123; - peg$currPos += 2; + if (s6 !== peg$FAILED) { + s7 = peg$parseaAssign(); + if (s7 !== peg$FAILED) { + peg$savedPos = s3; + s4 = peg$c185(s1, s7); + s3 = s4; } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c124); } + peg$currPos = s3; + s3 = peg$FAILED; } - if (s2 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c118) { - s2 = peg$c118; - peg$currPos += 2; - } else { + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = []; + s5 = peg$parsespaceNL(); + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = peg$parsespaceNL(); + } + if (s4 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 44) { + s5 = peg$c183; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c184); } + } + if (s5 !== peg$FAILED) { + s6 = []; + s7 = peg$parsespaceNL(); + while (s7 !== peg$FAILED) { + s6.push(s7); + s7 = peg$parsespaceNL(); + } + if (s6 !== peg$FAILED) { + s7 = peg$parseaAssign(); + if (s7 !== peg$FAILED) { + peg$savedPos = s3; + s4 = peg$c185(s1, s7); + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c186(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c182); } + } + + return s0; + } + + function peg$parseaAssign() { + var s0, s1, s2, s3, s4, s5, s6; + + peg$silentFails++; + s0 = peg$currPos; + s1 = peg$parseaCond(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parsespaceNL(); + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parsespaceNL(); + } + if (s2 !== peg$FAILED) { + s3 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 61) { + s4 = peg$c72; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c73); } + } + if (s4 !== peg$FAILED) { + s5 = peg$currPos; + peg$silentFails++; + if (input.charCodeAt(peg$currPos) === 61) { + s6 = peg$c72; + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c73); } + } + peg$silentFails--; + if (s6 === peg$FAILED) { + s5 = void 0; + } else { + peg$currPos = s5; + s5 = peg$FAILED; + } + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + if (s3 === peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c188) { + s3 = peg$c188; + peg$currPos += 2; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c189); } + } + if (s3 === peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c190) { + s3 = peg$c190; + peg$currPos += 2; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c191); } + } + if (s3 === peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c192) { + s3 = peg$c192; + peg$currPos += 2; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c193); } + } + if (s3 === peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c194) { + s3 = peg$c194; + peg$currPos += 2; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c195); } + } + if (s3 === peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c196) { + s3 = peg$c196; + peg$currPos += 2; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c197); } + } + if (s3 === peg$FAILED) { + if (input.substr(peg$currPos, 3) === peg$c198) { + s3 = peg$c198; + peg$currPos += 3; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c199); } + } + if (s3 === peg$FAILED) { + if (input.substr(peg$currPos, 3) === peg$c200) { + s3 = peg$c200; + peg$currPos += 3; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c201); } + } + if (s3 === peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c202) { + s3 = peg$c202; + peg$currPos += 2; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c203); } + } + if (s3 === peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c204) { + s3 = peg$c204; + peg$currPos += 2; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c205); } + } + if (s3 === peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c206) { + s3 = peg$c206; + peg$currPos += 2; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c207); } + } + } + } + } + } + } + } + } + } + } + } + if (s3 !== peg$FAILED) { + s4 = []; + s5 = peg$parsespaceNL(); + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = peg$parsespaceNL(); + } + if (s4 !== peg$FAILED) { + s5 = peg$parseaAssign(); + if (s5 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c208(s1, s3, s5); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parseaCond(); + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c209(s1); + } + s0 = s1; + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c187); } + } + + return s0; + } + + function peg$parseaCond() { + var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; + + peg$silentFails++; + s0 = peg$currPos; + s1 = peg$parseaLogicalOr(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parsespaceNL(); + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parsespaceNL(); + } + if (s2 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 63) { + s3 = peg$c96; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c97); } + } + if (s3 !== peg$FAILED) { + s4 = []; + s5 = peg$parsespaceNL(); + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = peg$parsespaceNL(); + } + if (s4 !== peg$FAILED) { + s5 = peg$parseaAssign(); + if (s5 !== peg$FAILED) { + s6 = []; + s7 = peg$parsespaceNL(); + while (s7 !== peg$FAILED) { + s6.push(s7); + s7 = peg$parsespaceNL(); + } + if (s6 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 58) { + s7 = peg$c211; + peg$currPos++; + } else { + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c212); } + } + if (s7 !== peg$FAILED) { + s8 = []; + s9 = peg$parsespaceNL(); + while (s9 !== peg$FAILED) { + s8.push(s9); + s9 = peg$parsespaceNL(); + } + if (s8 !== peg$FAILED) { + s9 = peg$parseaAssign(); + if (s9 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c213(s1, s5, s9); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parseaLogicalOr(); + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c209(s1); + } + s0 = s1; + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c210); } + } + + return s0; + } + + function peg$parseaLogicalOr() { + var s0, s1, s2, s3, s4, s5, s6, s7; + + peg$silentFails++; + s0 = peg$currPos; + s1 = peg$parseaLogicalAnd(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = []; + s5 = peg$parsespaceNL(); + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = peg$parsespaceNL(); + } + if (s4 !== peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c5) { + s5 = peg$c5; + peg$currPos += 2; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c6); } + } + if (s5 !== peg$FAILED) { + s6 = []; + s7 = peg$parsespaceNL(); + while (s7 !== peg$FAILED) { + s6.push(s7); + s7 = peg$parsespaceNL(); + } + if (s6 !== peg$FAILED) { + s7 = peg$parseaLogicalAnd(); + if (s7 !== peg$FAILED) { + peg$savedPos = s3; + s4 = peg$c215(s1, s5, s7); + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = []; + s5 = peg$parsespaceNL(); + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = peg$parsespaceNL(); + } + if (s4 !== peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c5) { + s5 = peg$c5; + peg$currPos += 2; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c6); } + } + if (s5 !== peg$FAILED) { + s6 = []; + s7 = peg$parsespaceNL(); + while (s7 !== peg$FAILED) { + s6.push(s7); + s7 = peg$parsespaceNL(); + } + if (s6 !== peg$FAILED) { + s7 = peg$parseaLogicalAnd(); + if (s7 !== peg$FAILED) { + peg$savedPos = s3; + s4 = peg$c215(s1, s5, s7); + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c216(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c214); } + } + + return s0; + } + + function peg$parseaLogicalAnd() { + var s0, s1, s2, s3, s4, s5, s6, s7; + + peg$silentFails++; + s0 = peg$currPos; + s1 = peg$parseaBitwiseOr(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = []; + s5 = peg$parsespaceNL(); + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = peg$parsespaceNL(); + } + if (s4 !== peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c3) { + s5 = peg$c3; + peg$currPos += 2; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c4); } + } + if (s5 !== peg$FAILED) { + s6 = []; + s7 = peg$parsespaceNL(); + while (s7 !== peg$FAILED) { + s6.push(s7); + s7 = peg$parsespaceNL(); + } + if (s6 !== peg$FAILED) { + s7 = peg$parseaBitwiseOr(); + if (s7 !== peg$FAILED) { + peg$savedPos = s3; + s4 = peg$c215(s1, s5, s7); + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = []; + s5 = peg$parsespaceNL(); + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = peg$parsespaceNL(); + } + if (s4 !== peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c3) { + s5 = peg$c3; + peg$currPos += 2; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c4); } + } + if (s5 !== peg$FAILED) { + s6 = []; + s7 = peg$parsespaceNL(); + while (s7 !== peg$FAILED) { + s6.push(s7); + s7 = peg$parsespaceNL(); + } + if (s6 !== peg$FAILED) { + s7 = peg$parseaBitwiseOr(); + if (s7 !== peg$FAILED) { + peg$savedPos = s3; + s4 = peg$c215(s1, s5, s7); + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c216(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c217); } + } + + return s0; + } + + function peg$parseaBitwiseOr() { + var s0, s1, s2, s3, s4, s5, s6, s7, s8; + + s0 = peg$currPos; + s1 = peg$parseaBitwiseXor(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = []; + s5 = peg$parsespaceNL(); + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = peg$parsespaceNL(); + } + if (s4 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 124) { + s5 = peg$c167; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c168); } + } + if (s5 !== peg$FAILED) { + s6 = peg$currPos; + peg$silentFails++; + if (peg$c218.test(input.charAt(peg$currPos))) { + s7 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c219); } + } + peg$silentFails--; + if (s7 === peg$FAILED) { + s6 = void 0; + } else { + peg$currPos = s6; + s6 = peg$FAILED; + } + if (s6 !== peg$FAILED) { + s7 = []; + s8 = peg$parsespaceNL(); + while (s8 !== peg$FAILED) { + s7.push(s8); + s8 = peg$parsespaceNL(); + } + if (s7 !== peg$FAILED) { + s8 = peg$parseaBitwiseXor(); + if (s8 !== peg$FAILED) { + peg$savedPos = s3; + s4 = peg$c215(s1, s5, s8); + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = []; + s5 = peg$parsespaceNL(); + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = peg$parsespaceNL(); + } + if (s4 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 124) { + s5 = peg$c167; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c168); } + } + if (s5 !== peg$FAILED) { + s6 = peg$currPos; + peg$silentFails++; + if (peg$c218.test(input.charAt(peg$currPos))) { + s7 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c219); } + } + peg$silentFails--; + if (s7 === peg$FAILED) { + s6 = void 0; + } else { + peg$currPos = s6; + s6 = peg$FAILED; + } + if (s6 !== peg$FAILED) { + s7 = []; + s8 = peg$parsespaceNL(); + while (s8 !== peg$FAILED) { + s7.push(s8); + s8 = peg$parsespaceNL(); + } + if (s7 !== peg$FAILED) { + s8 = peg$parseaBitwiseXor(); + if (s8 !== peg$FAILED) { + peg$savedPos = s3; + s4 = peg$c215(s1, s5, s8); + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c220(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseaBitwiseXor() { + var s0, s1, s2, s3, s4, s5, s6, s7, s8; + + s0 = peg$currPos; + s1 = peg$parseaBitwiseAnd(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = []; + s5 = peg$parsespaceNL(); + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = peg$parsespaceNL(); + } + if (s4 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 94) { + s5 = peg$c221; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c222); } + } + if (s5 !== peg$FAILED) { + s6 = peg$currPos; + peg$silentFails++; + if (input.charCodeAt(peg$currPos) === 61) { + s7 = peg$c72; + peg$currPos++; + } else { + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c73); } + } + peg$silentFails--; + if (s7 === peg$FAILED) { + s6 = void 0; + } else { + peg$currPos = s6; + s6 = peg$FAILED; + } + if (s6 !== peg$FAILED) { + s7 = []; + s8 = peg$parsespaceNL(); + while (s8 !== peg$FAILED) { + s7.push(s8); + s8 = peg$parsespaceNL(); + } + if (s7 !== peg$FAILED) { + s8 = peg$parseaBitwiseAnd(); + if (s8 !== peg$FAILED) { + peg$savedPos = s3; + s4 = peg$c215(s1, s5, s8); + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = []; + s5 = peg$parsespaceNL(); + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = peg$parsespaceNL(); + } + if (s4 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 94) { + s5 = peg$c221; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c222); } + } + if (s5 !== peg$FAILED) { + s6 = peg$currPos; + peg$silentFails++; + if (input.charCodeAt(peg$currPos) === 61) { + s7 = peg$c72; + peg$currPos++; + } else { + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c73); } + } + peg$silentFails--; + if (s7 === peg$FAILED) { + s6 = void 0; + } else { + peg$currPos = s6; + s6 = peg$FAILED; + } + if (s6 !== peg$FAILED) { + s7 = []; + s8 = peg$parsespaceNL(); + while (s8 !== peg$FAILED) { + s7.push(s8); + s8 = peg$parsespaceNL(); + } + if (s7 !== peg$FAILED) { + s8 = peg$parseaBitwiseAnd(); + if (s8 !== peg$FAILED) { + peg$savedPos = s3; + s4 = peg$c215(s1, s5, s8); + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c220(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseaBitwiseAnd() { + var s0, s1, s2, s3, s4, s5, s6, s7, s8; + + s0 = peg$currPos; + s1 = peg$parseaEquality(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = []; + s5 = peg$parsespaceNL(); + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = peg$parsespaceNL(); + } + if (s4 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 38) { + s5 = peg$c164; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c165); } + } + if (s5 !== peg$FAILED) { + s6 = peg$currPos; + peg$silentFails++; + if (peg$c223.test(input.charAt(peg$currPos))) { + s7 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c224); } + } + peg$silentFails--; + if (s7 === peg$FAILED) { + s6 = void 0; + } else { + peg$currPos = s6; + s6 = peg$FAILED; + } + if (s6 !== peg$FAILED) { + s7 = []; + s8 = peg$parsespaceNL(); + while (s8 !== peg$FAILED) { + s7.push(s8); + s8 = peg$parsespaceNL(); + } + if (s7 !== peg$FAILED) { + s8 = peg$parseaEquality(); + if (s8 !== peg$FAILED) { + peg$savedPos = s3; + s4 = peg$c215(s1, s5, s8); + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = []; + s5 = peg$parsespaceNL(); + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = peg$parsespaceNL(); + } + if (s4 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 38) { + s5 = peg$c164; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c165); } + } + if (s5 !== peg$FAILED) { + s6 = peg$currPos; + peg$silentFails++; + if (peg$c223.test(input.charAt(peg$currPos))) { + s7 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c224); } + } + peg$silentFails--; + if (s7 === peg$FAILED) { + s6 = void 0; + } else { + peg$currPos = s6; + s6 = peg$FAILED; + } + if (s6 !== peg$FAILED) { + s7 = []; + s8 = peg$parsespaceNL(); + while (s8 !== peg$FAILED) { + s7.push(s8); + s8 = peg$parsespaceNL(); + } + if (s7 !== peg$FAILED) { + s8 = peg$parseaEquality(); + if (s8 !== peg$FAILED) { + peg$savedPos = s3; + s4 = peg$c215(s1, s5, s8); + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c220(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseaEquality() { + var s0, s1, s2, s3, s4, s5, s6, s7; + + s0 = peg$currPos; + s1 = peg$parseaComparison(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = []; + s5 = peg$parsespaceNL(); + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = peg$parsespaceNL(); + } + if (s4 !== peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c225) { + s5 = peg$c225; + peg$currPos += 2; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c226); } + } + if (s5 === peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c227) { + s5 = peg$c227; + peg$currPos += 2; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c228); } + } + } + if (s5 !== peg$FAILED) { + s6 = []; + s7 = peg$parsespaceNL(); + while (s7 !== peg$FAILED) { + s6.push(s7); + s7 = peg$parsespaceNL(); + } + if (s6 !== peg$FAILED) { + s7 = peg$parseaComparison(); + if (s7 !== peg$FAILED) { + peg$savedPos = s3; + s4 = peg$c215(s1, s5, s7); + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = []; + s5 = peg$parsespaceNL(); + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = peg$parsespaceNL(); + } + if (s4 !== peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c225) { + s5 = peg$c225; + peg$currPos += 2; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c226); } + } + if (s5 === peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c227) { + s5 = peg$c227; + peg$currPos += 2; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c228); } + } + } + if (s5 !== peg$FAILED) { + s6 = []; + s7 = peg$parsespaceNL(); + while (s7 !== peg$FAILED) { + s6.push(s7); + s7 = peg$parsespaceNL(); + } + if (s6 !== peg$FAILED) { + s7 = peg$parseaComparison(); + if (s7 !== peg$FAILED) { + peg$savedPos = s3; + s4 = peg$c215(s1, s5, s7); + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c220(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseaComparison() { + var s0, s1, s2, s3, s4, s5, s6, s7, s8; + + s0 = peg$currPos; + s1 = peg$parseaBitwiseShift(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = []; + s5 = peg$parsespaceNL(); + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = peg$parsespaceNL(); + } + if (s4 !== peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c229) { + s5 = peg$c229; + peg$currPos += 2; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c230); } + } + if (s5 === peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c231) { + s5 = peg$c231; + peg$currPos += 2; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c232); } + } + if (s5 === peg$FAILED) { + s5 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 60) { + s6 = peg$c157; + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c158); } + } + if (s6 !== peg$FAILED) { + s7 = peg$currPos; + peg$silentFails++; + if (input.charCodeAt(peg$currPos) === 60) { + s8 = peg$c157; + peg$currPos++; + } else { + s8 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c158); } + } + peg$silentFails--; + if (s8 === peg$FAILED) { + s7 = void 0; + } else { + peg$currPos = s7; + s7 = peg$FAILED; + } + if (s7 !== peg$FAILED) { + peg$savedPos = s5; + s6 = peg$c233(s1, s6); + s5 = s6; + } else { + peg$currPos = s5; + s5 = peg$FAILED; + } + } else { + peg$currPos = s5; + s5 = peg$FAILED; + } + if (s5 === peg$FAILED) { + s5 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 62) { + s6 = peg$c159; + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c160); } + } + if (s6 !== peg$FAILED) { + s7 = peg$currPos; + peg$silentFails++; + if (input.charCodeAt(peg$currPos) === 62) { + s8 = peg$c159; + peg$currPos++; + } else { + s8 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c160); } + } + peg$silentFails--; + if (s8 === peg$FAILED) { + s7 = void 0; + } else { + peg$currPos = s7; + s7 = peg$FAILED; + } + if (s7 !== peg$FAILED) { + peg$savedPos = s5; + s6 = peg$c233(s1, s6); + s5 = s6; + } else { + peg$currPos = s5; + s5 = peg$FAILED; + } + } else { + peg$currPos = s5; + s5 = peg$FAILED; + } + } + } + } + if (s5 !== peg$FAILED) { + s6 = []; + s7 = peg$parsespaceNL(); + while (s7 !== peg$FAILED) { + s6.push(s7); + s7 = peg$parsespaceNL(); + } + if (s6 !== peg$FAILED) { + s7 = peg$parseaBitwiseShift(); + if (s7 !== peg$FAILED) { + peg$savedPos = s3; + s4 = peg$c215(s1, s5, s7); + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = []; + s5 = peg$parsespaceNL(); + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = peg$parsespaceNL(); + } + if (s4 !== peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c229) { + s5 = peg$c229; + peg$currPos += 2; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c230); } + } + if (s5 === peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c231) { + s5 = peg$c231; + peg$currPos += 2; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c232); } + } + if (s5 === peg$FAILED) { + s5 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 60) { + s6 = peg$c157; + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c158); } + } + if (s6 !== peg$FAILED) { + s7 = peg$currPos; + peg$silentFails++; + if (input.charCodeAt(peg$currPos) === 60) { + s8 = peg$c157; + peg$currPos++; + } else { + s8 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c158); } + } + peg$silentFails--; + if (s8 === peg$FAILED) { + s7 = void 0; + } else { + peg$currPos = s7; + s7 = peg$FAILED; + } + if (s7 !== peg$FAILED) { + peg$savedPos = s5; + s6 = peg$c233(s1, s6); + s5 = s6; + } else { + peg$currPos = s5; + s5 = peg$FAILED; + } + } else { + peg$currPos = s5; + s5 = peg$FAILED; + } + if (s5 === peg$FAILED) { + s5 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 62) { + s6 = peg$c159; + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c160); } + } + if (s6 !== peg$FAILED) { + s7 = peg$currPos; + peg$silentFails++; + if (input.charCodeAt(peg$currPos) === 62) { + s8 = peg$c159; + peg$currPos++; + } else { + s8 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c160); } + } + peg$silentFails--; + if (s8 === peg$FAILED) { + s7 = void 0; + } else { + peg$currPos = s7; + s7 = peg$FAILED; + } + if (s7 !== peg$FAILED) { + peg$savedPos = s5; + s6 = peg$c233(s1, s6); + s5 = s6; + } else { + peg$currPos = s5; + s5 = peg$FAILED; + } + } else { + peg$currPos = s5; + s5 = peg$FAILED; + } + } + } + } + if (s5 !== peg$FAILED) { + s6 = []; + s7 = peg$parsespaceNL(); + while (s7 !== peg$FAILED) { + s6.push(s7); + s7 = peg$parsespaceNL(); + } + if (s6 !== peg$FAILED) { + s7 = peg$parseaBitwiseShift(); + if (s7 !== peg$FAILED) { + peg$savedPos = s3; + s4 = peg$c215(s1, s5, s7); + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c220(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseaBitwiseShift() { + var s0, s1, s2, s3, s4, s5, s6, s7, s8; + + s0 = peg$currPos; + s1 = peg$parseaAddSubtract(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = []; + s5 = peg$parsespaceNL(); + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = peg$parsespaceNL(); + } + if (s4 !== peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c234) { + s5 = peg$c234; + peg$currPos += 2; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c235); } + } + if (s5 === peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c151) { + s5 = peg$c151; + peg$currPos += 2; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c152); } + } + } + if (s5 !== peg$FAILED) { + s6 = peg$currPos; + peg$silentFails++; + if (input.charCodeAt(peg$currPos) === 61) { + s7 = peg$c72; + peg$currPos++; + } else { + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c73); } + } + peg$silentFails--; + if (s7 === peg$FAILED) { + s6 = void 0; + } else { + peg$currPos = s6; + s6 = peg$FAILED; + } + if (s6 !== peg$FAILED) { + s7 = []; + s8 = peg$parsespaceNL(); + while (s8 !== peg$FAILED) { + s7.push(s8); + s8 = peg$parsespaceNL(); + } + if (s7 !== peg$FAILED) { + s8 = peg$parseaAddSubtract(); + if (s8 !== peg$FAILED) { + peg$savedPos = s3; + s4 = peg$c215(s1, s5, s8); + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = []; + s5 = peg$parsespaceNL(); + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = peg$parsespaceNL(); + } + if (s4 !== peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c234) { + s5 = peg$c234; + peg$currPos += 2; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c235); } + } + if (s5 === peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c151) { + s5 = peg$c151; + peg$currPos += 2; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c152); } + } + } + if (s5 !== peg$FAILED) { + s6 = peg$currPos; + peg$silentFails++; + if (input.charCodeAt(peg$currPos) === 61) { + s7 = peg$c72; + peg$currPos++; + } else { + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c73); } + } + peg$silentFails--; + if (s7 === peg$FAILED) { + s6 = void 0; + } else { + peg$currPos = s6; + s6 = peg$FAILED; + } + if (s6 !== peg$FAILED) { + s7 = []; + s8 = peg$parsespaceNL(); + while (s8 !== peg$FAILED) { + s7.push(s8); + s8 = peg$parsespaceNL(); + } + if (s7 !== peg$FAILED) { + s8 = peg$parseaAddSubtract(); + if (s8 !== peg$FAILED) { + peg$savedPos = s3; + s4 = peg$c215(s1, s5, s8); + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c220(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseaAddSubtract() { + var s0, s1, s2, s3, s4, s5, s6, s7, s8; + + s0 = peg$currPos; + s1 = peg$parseaMultDivModulo(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = []; + s5 = peg$parsespaceNL(); + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = peg$parsespaceNL(); + } + if (s4 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 43) { + s5 = peg$c236; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c237); } + } + if (s5 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 45) { + s5 = peg$c59; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c60); } + } + } + if (s5 !== peg$FAILED) { + s6 = peg$currPos; + peg$silentFails++; + if (input.charCodeAt(peg$currPos) === 61) { + s7 = peg$c72; + peg$currPos++; + } else { + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c73); } + } + peg$silentFails--; + if (s7 === peg$FAILED) { + s6 = void 0; + } else { + peg$currPos = s6; + s6 = peg$FAILED; + } + if (s6 !== peg$FAILED) { + s7 = []; + s8 = peg$parsespaceNL(); + while (s8 !== peg$FAILED) { + s7.push(s8); + s8 = peg$parsespaceNL(); + } + if (s7 !== peg$FAILED) { + s8 = peg$parseaMultDivModulo(); + if (s8 !== peg$FAILED) { + peg$savedPos = s3; + s4 = peg$c215(s1, s5, s8); + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = []; + s5 = peg$parsespaceNL(); + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = peg$parsespaceNL(); + } + if (s4 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 43) { + s5 = peg$c236; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c237); } + } + if (s5 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 45) { + s5 = peg$c59; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c60); } + } + } + if (s5 !== peg$FAILED) { + s6 = peg$currPos; + peg$silentFails++; + if (input.charCodeAt(peg$currPos) === 61) { + s7 = peg$c72; + peg$currPos++; + } else { + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c73); } + } + peg$silentFails--; + if (s7 === peg$FAILED) { + s6 = void 0; + } else { + peg$currPos = s6; + s6 = peg$FAILED; + } + if (s6 !== peg$FAILED) { + s7 = []; + s8 = peg$parsespaceNL(); + while (s8 !== peg$FAILED) { + s7.push(s8); + s8 = peg$parsespaceNL(); + } + if (s7 !== peg$FAILED) { + s8 = peg$parseaMultDivModulo(); + if (s8 !== peg$FAILED) { + peg$savedPos = s3; + s4 = peg$c215(s1, s5, s8); + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c220(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseaMultDivModulo() { + var s0, s1, s2, s3, s4, s5, s6, s7, s8; + + s0 = peg$currPos; + s1 = peg$parseaExponent(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = []; + s5 = peg$parsespaceNL(); + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = peg$parsespaceNL(); + } + if (s4 !== peg$FAILED) { + s5 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 42) { + s6 = peg$c94; + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c95); } + } + if (s6 !== peg$FAILED) { + s7 = peg$currPos; + peg$silentFails++; + if (input.charCodeAt(peg$currPos) === 42) { + s8 = peg$c94; + peg$currPos++; + } else { + s8 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c95); } + } + peg$silentFails--; + if (s8 === peg$FAILED) { + s7 = void 0; + } else { + peg$currPos = s7; + s7 = peg$FAILED; + } + if (s7 !== peg$FAILED) { + peg$savedPos = s5; + s6 = peg$c233(s1, s6); + s5 = s6; + } else { + peg$currPos = s5; + s5 = peg$FAILED; + } + } else { + peg$currPos = s5; + s5 = peg$FAILED; + } + if (s5 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 47) { + s5 = peg$c238; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c239); } + } + if (s5 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 37) { + s5 = peg$c240; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c241); } + } + } + } + if (s5 !== peg$FAILED) { + s6 = peg$currPos; + peg$silentFails++; + if (input.charCodeAt(peg$currPos) === 61) { + s7 = peg$c72; + peg$currPos++; + } else { + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c73); } + } + peg$silentFails--; + if (s7 === peg$FAILED) { + s6 = void 0; + } else { + peg$currPos = s6; + s6 = peg$FAILED; + } + if (s6 !== peg$FAILED) { + s7 = []; + s8 = peg$parsespaceNL(); + while (s8 !== peg$FAILED) { + s7.push(s8); + s8 = peg$parsespaceNL(); + } + if (s7 !== peg$FAILED) { + s8 = peg$parseaExponent(); + if (s8 !== peg$FAILED) { + peg$savedPos = s3; + s4 = peg$c215(s1, s5, s8); + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = []; + s5 = peg$parsespaceNL(); + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = peg$parsespaceNL(); + } + if (s4 !== peg$FAILED) { + s5 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 42) { + s6 = peg$c94; + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c95); } + } + if (s6 !== peg$FAILED) { + s7 = peg$currPos; + peg$silentFails++; + if (input.charCodeAt(peg$currPos) === 42) { + s8 = peg$c94; + peg$currPos++; + } else { + s8 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c95); } + } + peg$silentFails--; + if (s8 === peg$FAILED) { + s7 = void 0; + } else { + peg$currPos = s7; + s7 = peg$FAILED; + } + if (s7 !== peg$FAILED) { + peg$savedPos = s5; + s6 = peg$c233(s1, s6); + s5 = s6; + } else { + peg$currPos = s5; + s5 = peg$FAILED; + } + } else { + peg$currPos = s5; + s5 = peg$FAILED; + } + if (s5 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 47) { + s5 = peg$c238; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c239); } + } + if (s5 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 37) { + s5 = peg$c240; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c241); } + } + } + } + if (s5 !== peg$FAILED) { + s6 = peg$currPos; + peg$silentFails++; + if (input.charCodeAt(peg$currPos) === 61) { + s7 = peg$c72; + peg$currPos++; + } else { + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c73); } + } + peg$silentFails--; + if (s7 === peg$FAILED) { + s6 = void 0; + } else { + peg$currPos = s6; + s6 = peg$FAILED; + } + if (s6 !== peg$FAILED) { + s7 = []; + s8 = peg$parsespaceNL(); + while (s8 !== peg$FAILED) { + s7.push(s8); + s8 = peg$parsespaceNL(); + } + if (s7 !== peg$FAILED) { + s8 = peg$parseaExponent(); + if (s8 !== peg$FAILED) { + peg$savedPos = s3; + s4 = peg$c215(s1, s5, s8); + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c220(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseaExponent() { + var s0, s1, s2, s3, s4, s5, s6, s7; + + s0 = peg$currPos; + s1 = peg$parseaNegation(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = []; + s5 = peg$parsespaceNL(); + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = peg$parsespaceNL(); + } + if (s4 !== peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c242) { + s5 = peg$c242; + peg$currPos += 2; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c243); } + } + if (s5 !== peg$FAILED) { + s6 = []; + s7 = peg$parsespaceNL(); + while (s7 !== peg$FAILED) { + s6.push(s7); + s7 = peg$parsespaceNL(); + } + if (s6 !== peg$FAILED) { + s7 = peg$parseaNegation(); + if (s7 !== peg$FAILED) { + peg$savedPos = s3; + s4 = peg$c215(s1, s5, s7); + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = []; + s5 = peg$parsespaceNL(); + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = peg$parsespaceNL(); + } + if (s4 !== peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c242) { + s5 = peg$c242; + peg$currPos += 2; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c243); } + } + if (s5 !== peg$FAILED) { + s6 = []; + s7 = peg$parsespaceNL(); + while (s7 !== peg$FAILED) { + s6.push(s7); + s7 = peg$parsespaceNL(); + } + if (s6 !== peg$FAILED) { + s7 = peg$parseaNegation(); + if (s7 !== peg$FAILED) { + peg$savedPos = s3; + s4 = peg$c215(s1, s5, s7); + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c220(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseaNegation() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 33) { + s1 = peg$c244; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c245); } + } + if (s1 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 126) { + s1 = peg$c246; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c247); } + } + } + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parsespaceNL(); + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parsespaceNL(); + } + if (s2 !== peg$FAILED) { + s3 = peg$parseaNegation(); + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c248(s1, s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parseaUnary(); + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c209(s1); + } + s0 = s1; + } + + return s0; + } + + function peg$parseaUnary() { + var s0, s1, s2, s3, s4; + + s0 = peg$currPos; + s1 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 43) { + s2 = peg$c236; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c237); } + } + if (s2 !== peg$FAILED) { + s3 = peg$currPos; + peg$silentFails++; + if (peg$c249.test(input.charAt(peg$currPos))) { + s4 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c250); } + } + peg$silentFails--; + if (s4 === peg$FAILED) { + s3 = void 0; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + if (s3 !== peg$FAILED) { + peg$savedPos = s1; + s2 = peg$c251(s2); + s1 = s2; + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + if (s1 === peg$FAILED) { + s1 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 45) { + s2 = peg$c59; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c60); } + } + if (s2 !== peg$FAILED) { + s3 = peg$currPos; + peg$silentFails++; + if (peg$c252.test(input.charAt(peg$currPos))) { + s4 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c253); } + } + peg$silentFails--; + if (s4 === peg$FAILED) { + s3 = void 0; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + if (s3 !== peg$FAILED) { + peg$savedPos = s1; + s2 = peg$c251(s2); + s1 = s2; + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parsespaceNL(); + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parsespaceNL(); + } + if (s2 !== peg$FAILED) { + s3 = peg$parseaUnary(); + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c248(s1, s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parseaPreIncDec(); + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c209(s1); + } + s0 = s1; + } + + return s0; + } + + function peg$parseaPreIncDec() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 2) === peg$c254) { + s1 = peg$c254; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c255); } + } + if (s1 === peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c256) { + s1 = peg$c256; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c257); } + } + } + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parsespaceNL(); + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parsespaceNL(); + } + if (s2 !== peg$FAILED) { + s3 = peg$parseaPreIncDec(); + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c258(s1, s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parseaPostIncDec(); + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c209(s1); + } + s0 = s1; + } + + return s0; + } + + function peg$parseaPostIncDec() { + var s0, s1, s2, s3, s4, s5; + + s0 = peg$currPos; + s1 = peg$parseaMemberExpr(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = []; + s5 = peg$parsespaceNL(); + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = peg$parsespaceNL(); + } + if (s4 !== peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c254) { + s5 = peg$c254; + peg$currPos += 2; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c255); } + } + if (s5 === peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c256) { + s5 = peg$c256; + peg$currPos += 2; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c257); } + } + } + if (s5 !== peg$FAILED) { + peg$savedPos = s3; + s4 = peg$c259(s1, s5); + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + if (s3 !== peg$FAILED) { + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = []; + s5 = peg$parsespaceNL(); + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = peg$parsespaceNL(); + } + if (s4 !== peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c254) { + s5 = peg$c254; + peg$currPos += 2; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c255); } + } + if (s5 === peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c256) { + s5 = peg$c256; + peg$currPos += 2; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c257); } + } + } + if (s5 !== peg$FAILED) { + peg$savedPos = s3; + s4 = peg$c259(s1, s5); + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + } else { + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c260(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parseaMemberExpr(); + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c209(s1); + } + s0 = s1; + } + + return s0; + } + + function peg$parseaMemberExpr() { + var s0, s1, s2, s3, s4, s5, s6, s7; + + s0 = peg$currPos; + s1 = peg$parseaParenExpr(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = []; + s5 = peg$parsespaceNL(); + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = peg$parsespaceNL(); + } + if (s4 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 91) { + s5 = peg$c79; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c80); } + } + if (s5 !== peg$FAILED) { + s6 = peg$parsearithmetic(); + if (s6 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 93) { + s7 = peg$c99; + peg$currPos++; + } else { + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c100); } + } + if (s7 !== peg$FAILED) { + peg$savedPos = s3; + s4 = peg$c261(s1, s6); + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = []; + s5 = peg$parsespaceNL(); + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = peg$parsespaceNL(); + } + if (s4 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 91) { + s5 = peg$c79; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c80); } + } + if (s5 !== peg$FAILED) { + s6 = peg$parsearithmetic(); + if (s6 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 93) { + s7 = peg$c99; + peg$currPos++; + } else { + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c100); } + } + if (s7 !== peg$FAILED) { + peg$savedPos = s3; + s4 = peg$c261(s1, s6); + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c262(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseaParenExpr() { + var s0, s1, s2, s3, s4, s5; + + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 40) { + s1 = peg$c15; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c16); } + } + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parsespaceNL(); + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parsespaceNL(); + } + if (s2 !== peg$FAILED) { + s3 = peg$parsearithmetic(); + if (s3 !== peg$FAILED) { + s4 = []; + s5 = peg$parsespaceNL(); + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = peg$parsespaceNL(); + } + if (s4 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 41) { + s5 = peg$c17; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c18); } + } + if (s5 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c263(s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parseaLiteral(); + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c209(s1); + } + s0 = s1; + } + + return s0; + } + + function peg$parseaBareword() { + var s0, s1, s2, s3; + + peg$silentFails++; + s0 = peg$currPos; + s1 = peg$currPos; + peg$silentFails++; + if (input.charCodeAt(peg$currPos) === 35) { + s2 = peg$c85; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c86); } + } + peg$silentFails--; + if (s2 === peg$FAILED) { + s1 = void 0; + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parseaBarewordChar(); + if (s3 !== peg$FAILED) { + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parseaBarewordChar(); + } + } else { + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c265(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c264); } + } + + return s0; + } + + function peg$parseaBarewordChar() { + var s0, s1, s2; + + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 92) { + s1 = peg$c88; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c89); } + } + if (s1 !== peg$FAILED) { + s2 = peg$parseaBarewordMeta(); + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c90(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$currPos; + peg$silentFails++; + s2 = peg$parseaBarewordMeta(); + peg$silentFails--; + if (s2 === peg$FAILED) { + s1 = void 0; + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + if (s1 !== peg$FAILED) { + if (input.length > peg$currPos) { + s2 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c91); } + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c90(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } + + return s0; + } + + function peg$parseaBarewordMeta() { + var s0; + + if (peg$c266.test(input.charAt(peg$currPos))) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c267); } + } + + return s0; + } + + function peg$parseaConcatenation() { + var s0, s1, s2; + + peg$silentFails++; + s0 = peg$currPos; + s1 = []; + s2 = peg$parseaBareword(); + if (s2 === peg$FAILED) { + s2 = peg$parseenvironmentVariable(); + if (s2 === peg$FAILED) { + s2 = peg$parsevariableSubstitution(); + if (s2 === peg$FAILED) { + s2 = peg$parsearithmeticSubstitution(); + if (s2 === peg$FAILED) { + s2 = peg$parsecommandSubstitution(); + if (s2 === peg$FAILED) { + s2 = peg$parsesingleQuote(); + if (s2 === peg$FAILED) { + s2 = peg$parsedoubleQuote(); + } + } + } + } + } + } + if (s2 !== peg$FAILED) { + while (s2 !== peg$FAILED) { + s1.push(s2); + s2 = peg$parseaBareword(); + if (s2 === peg$FAILED) { + s2 = peg$parseenvironmentVariable(); + if (s2 === peg$FAILED) { + s2 = peg$parsevariableSubstitution(); + if (s2 === peg$FAILED) { + s2 = peg$parsearithmeticSubstitution(); + if (s2 === peg$FAILED) { + s2 = peg$parsecommandSubstitution(); + if (s2 === peg$FAILED) { + s2 = peg$parsesingleQuote(); + if (s2 === peg$FAILED) { + s2 = peg$parsedoubleQuote(); + } + } + } + } + } + } + } + } else { + s1 = peg$FAILED; + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c268(s1); + } + s0 = s1; + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c82); } + } + + return s0; + } + + function peg$parseaLiteral() { + var s0, s1; + + s0 = peg$currPos; + s1 = peg$parseaNumber(); + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c269(s1); + } + s0 = s1; + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parseaConcatenation(); + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c269(s1); + } + s0 = s1; + } + + return s0; + } + + function peg$parseaNumber() { + var s0, s1, s2, s3, s4; + + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 48) { + s1 = peg$c270; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c271); } + } + if (s1 !== peg$FAILED) { + if (peg$c272.test(input.charAt(peg$currPos))) { + s2 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c273); } + } + if (s2 !== peg$FAILED) { + s3 = []; + if (peg$c274.test(input.charAt(peg$currPos))) { + s4 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c275); } + } + if (s4 !== peg$FAILED) { + while (s4 !== peg$FAILED) { + s3.push(s4); + if (peg$c274.test(input.charAt(peg$currPos))) { + s4 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c275); } + } + } + } else { + s3 = peg$FAILED; + } + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c276(s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = []; + if (peg$c161.test(input.charAt(peg$currPos))) { + s2 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c162); } + } + if (s2 !== peg$FAILED) { + while (s2 !== peg$FAILED) { + s1.push(s2); + if (peg$c161.test(input.charAt(peg$currPos))) { + s2 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c162); } + } + } + } else { + s1 = peg$FAILED; + } + if (s1 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 35) { + s2 = peg$c85; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c86); } + } + if (s2 !== peg$FAILED) { + s3 = []; + if (peg$c277.test(input.charAt(peg$currPos))) { + s4 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c278); } + } + if (s4 !== peg$FAILED) { + while (s4 !== peg$FAILED) { + s3.push(s4); + if (peg$c277.test(input.charAt(peg$currPos))) { + s4 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c278); } + } + } + } else { + s3 = peg$FAILED; + } + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c279(s1, s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 48) { + s1 = peg$c270; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c271); } + } + if (s1 !== peg$FAILED) { + s2 = []; + if (peg$c280.test(input.charAt(peg$currPos))) { + s3 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c281); } + } + if (s3 !== peg$FAILED) { + while (s3 !== peg$FAILED) { + s2.push(s3); + if (peg$c280.test(input.charAt(peg$currPos))) { + s3 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c281); } + } + } + } else { + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c282(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = []; + if (peg$c161.test(input.charAt(peg$currPos))) { + s2 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c162); } + } + if (s2 !== peg$FAILED) { + while (s2 !== peg$FAILED) { + s1.push(s2); + if (peg$c161.test(input.charAt(peg$currPos))) { + s2 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c162); } + } + } + } else { + s1 = peg$FAILED; + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c283(s1); + } + s0 = s1; + } + } + } + + return s0; + } + + function peg$parsecontinuationStart() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = peg$currPos; + peg$silentFails++; + s2 = peg$parsekeyword(); + if (s2 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 34) { + s2 = peg$c112; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c113); } + } + if (s2 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 39) { + s2 = peg$c107; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c108); } + } + if (s2 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 96) { + s2 = peg$c118; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c119); } + } + if (s2 === peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c129) { + s2 = peg$c129; + peg$currPos += 2; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c130); } + } + if (s2 === peg$FAILED) { + if (input.substr(peg$currPos, 3) === peg$c132) { + s2 = peg$c132; + peg$currPos += 3; + } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c119); } + if (peg$silentFails === 0) { peg$fail(peg$c133); } + } + if (s2 === peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c124) { + s2 = peg$c124; + peg$currPos += 2; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c125); } + } } } } @@ -3883,7 +7465,7 @@ var parser=(function() { peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c85); } + if (peg$silentFails === 0) { peg$fail(peg$c91); } } while (s3 !== peg$FAILED) { s2.push(s3); @@ -3892,7 +7474,7 @@ var parser=(function() { peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c85); } + if (peg$silentFails === 0) { peg$fail(peg$c91); } } } if (s2 !== peg$FAILED) { @@ -3920,7 +7502,7 @@ var parser=(function() { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c85); } + if (peg$silentFails === 0) { peg$fail(peg$c91); } } peg$silentFails--; if (s1 === peg$FAILED) { @@ -3985,6 +7567,13 @@ var parser=(function() { pieces: result } } + function buildTree(head, tail, createNode) { + var result = head; + for (var i = 0, l = tail.length; i < l; i++) { + result = createNode(result, tail[i]); + } + return result; + } peg$result = peg$startRuleFunction(); diff --git a/quickcheck.js b/quickcheck.js new file mode 100755 index 0000000..36c1c86 --- /dev/null +++ b/quickcheck.js @@ -0,0 +1,6 @@ +#!/usr/bin/env node + +const util = require('util') +var parser = require("./" + process.argv[2]) +var parse = parser.parse || parser; +process.stdout.write(JSON.stringify(parse(process.argv[3]), null, ' ')) diff --git a/tests/fixtures/shellcheck-tests/allspacing/ast.json b/tests/fixtures/shellcheck-tests/allspacing/ast.json new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/tests/fixtures/shellcheck-tests/allspacing/ast.json @@ -0,0 +1 @@ +[] diff --git a/tests/fixtures/shellcheck-tests/allspacing2/ast.json b/tests/fixtures/shellcheck-tests/allspacing2/ast.json new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/tests/fixtures/shellcheck-tests/allspacing2/ast.json @@ -0,0 +1 @@ +[] diff --git a/tests/fixtures/shellcheck-tests/allspacing3/ast.json b/tests/fixtures/shellcheck-tests/allspacing3/ast.json new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/tests/fixtures/shellcheck-tests/allspacing3/ast.json @@ -0,0 +1 @@ +[] diff --git a/tests/fixtures/shellcheck-tests/and-or/ast.json b/tests/fixtures/shellcheck-tests/and-or/ast.json new file mode 100644 index 0000000..c22415b --- /dev/null +++ b/tests/fixtures/shellcheck-tests/and-or/ast.json @@ -0,0 +1,43 @@ +[ + { + "type": "command", + "command": { + "type": "literal", + "value": "grep" + }, + "args": [ + { + "type": "literal", + "value": "-i" + }, + { + "type": "literal", + "value": "lol" + }, + { + "type": "literal", + "value": "foo" + } + ], + "redirects": [], + "env": {}, + "control": "||", + "next": { + "type": "command", + "command": { + "type": "literal", + "value": "exit" + }, + "args": [ + { + "type": "literal", + "value": "1" + } + ], + "redirects": [], + "env": {}, + "control": ";", + "next": null + } + } +] diff --git a/tests/fixtures/shellcheck-tests/arithmetic-expression/source.sh b/tests/fixtures/shellcheck-tests/arithmetic-expression/source.sh deleted file mode 100644 index 703a0db..0000000 --- a/tests/fixtures/shellcheck-tests/arithmetic-expression/source.sh +++ /dev/null @@ -1 +0,0 @@ -((a?b:c)) \ No newline at end of file diff --git a/tests/fixtures/shellcheck-tests/arithmetic1/ast.json b/tests/fixtures/shellcheck-tests/arithmetic1/ast.json new file mode 100644 index 0000000..d0d94d1 --- /dev/null +++ b/tests/fixtures/shellcheck-tests/arithmetic1/ast.json @@ -0,0 +1,29 @@ +[ + { + "type": "arithmeticStatement", + "expression": { + "type": "arithmeticBinary", + "operator": "+", + "left": { + "type": "arithmeticUpdate", + "operator": "++", + "argument": { + "type": "variable", + "name": "n" + }, + "prefix": false + }, + "right": { + "type": "arithmeticUpdate", + "operator": "++", + "argument": { + "type": "variable", + "name": "c" + }, + "prefix": true + } + }, + "control": ";", + "next": null + } +] diff --git a/tests/fixtures/shellcheck-tests/arithmetic10/ast.json b/tests/fixtures/shellcheck-tests/arithmetic10/ast.json new file mode 100644 index 0000000..e2fa118 --- /dev/null +++ b/tests/fixtures/shellcheck-tests/arithmetic10/ast.json @@ -0,0 +1,15 @@ +[ + { + "type": "arithmeticStatement", + "expression": { + "type": "arithmeticUnary", + "operator": "!", + "argument": { + "type": "variable", + "name": "?" + } + }, + "control": ";", + "next": null + } +] diff --git a/tests/fixtures/shellcheck-tests/arithmetic11/ast.json b/tests/fixtures/shellcheck-tests/arithmetic11/ast.json new file mode 100644 index 0000000..e37377b --- /dev/null +++ b/tests/fixtures/shellcheck-tests/arithmetic11/ast.json @@ -0,0 +1,19 @@ +[ + { + "type": "arithmeticStatement", + "expression": { + "type": "arithmeticBinary", + "left": { + "type": "number", + "value": 8 + }, + "operator": "*", + "right": { + "type": "number", + "value": 15 + } + }, + "control": ";", + "next": null + } +] diff --git a/tests/fixtures/shellcheck-tests/arithmetic12/ast.json b/tests/fixtures/shellcheck-tests/arithmetic12/ast.json new file mode 100644 index 0000000..d059078 --- /dev/null +++ b/tests/fixtures/shellcheck-tests/arithmetic12/ast.json @@ -0,0 +1,30 @@ +[ + { + "type": "arithmeticStatement", + "expression": { + "type": "arithmeticBinary", + "operator": "+", + "left": { + "type": "arithmeticSubstitution", + "expression": { + "type": "arithmeticBinary", + "operator": "+", + "left": { + "type": "number", + "value": 3 + }, + "right": { + "type": "number", + "value": 2 + } + } + }, + "right": { + "type": "literal", + "value": "37" + } + }, + "control": ";", + "next": null + } +] diff --git a/tests/fixtures/shellcheck-tests/arithmetic13/ast.json b/tests/fixtures/shellcheck-tests/arithmetic13/ast.json new file mode 100644 index 0000000..fbb025d --- /dev/null +++ b/tests/fixtures/shellcheck-tests/arithmetic13/ast.json @@ -0,0 +1,39 @@ +[ + { + "type": "arithmeticStatement", + "expression": { + "type": "arithmeticUpdate", + "operator": "++", + "argument": { + "type": "arithmeticMemberExpression", + "array": { + "type": "variable", + "name": "foo" + }, + "property": { + "type": "arithmeticBinary", + "operator": "+", + "left": { + "type": "arithmeticBinary", + "operator": "*", + "left": { + "type": "number", + "value": 9 + }, + "right": { + "type": "variable", + "name": "y" + } + }, + "right": { + "type": "variable", + "name": "x" + } + } + }, + "prefix": false + }, + "control": ";", + "next": null + } +] diff --git a/tests/fixtures/shellcheck-tests/arithmetic14/ast.json b/tests/fixtures/shellcheck-tests/arithmetic14/ast.json new file mode 100644 index 0000000..1292dfe --- /dev/null +++ b/tests/fixtures/shellcheck-tests/arithmetic14/ast.json @@ -0,0 +1,37 @@ +[ + { + "type": "arithmeticStatement", + "expression": { + "type": "arithmeticBinary", + "operator": "+", + "left": { + "type": "number", + "value": 1 + }, + "right": { + "type": "commandSubstitution", + "commands": [ + { + "type": "command", + "command": { + "type": "literal", + "value": "echo" + }, + "args": [ + { + "type": "literal", + "value": "2" + } + ], + "redirects": [], + "env": {}, + "control": ";", + "next": null + } + ] + } + }, + "control": ";", + "next": null + } +] diff --git a/tests/fixtures/shellcheck-tests/arithmetic15/ast.json b/tests/fixtures/shellcheck-tests/arithmetic15/ast.json new file mode 100644 index 0000000..66347f6 --- /dev/null +++ b/tests/fixtures/shellcheck-tests/arithmetic15/ast.json @@ -0,0 +1,73 @@ +[ + { + "type": "arithmeticStatement", + "expression": { + "type": "arithmeticBinary", + "operator": "+", + "left": { + "type": "arithmeticMemberExpression", + "array": { + "type": "variable", + "name": "foo" + }, + "property": { + "type": "arithmeticBinary", + "operator": "*", + "left": { + "type": "commandSubstitution", + "commands": [ + { + "type": "command", + "command": { + "type": "literal", + "value": "echo" + }, + "args": [ + { + "type": "literal", + "value": "foo" + } + ], + "redirects": [ + { + "type": "pipe", + "command": { + "type": "command", + "command": { + "type": "literal", + "value": "sed" + }, + "args": [ + { + "type": "literal", + "value": "s/foo/4/g" + } + ], + "redirects": [], + "env": {}, + "control": ";", + "next": null + } + } + ], + "env": {}, + "control": ";", + "next": null + } + ] + }, + "right": { + "type": "number", + "value": 3 + } + } + }, + "right": { + "type": "number", + "value": 4 + } + }, + "control": ";", + "next": null + } +] diff --git a/tests/fixtures/shellcheck-tests/arithmetic16/ast.json b/tests/fixtures/shellcheck-tests/arithmetic16/ast.json new file mode 100644 index 0000000..bfd6e93 --- /dev/null +++ b/tests/fixtures/shellcheck-tests/arithmetic16/ast.json @@ -0,0 +1,20 @@ +[ + { + "type": "arithmeticStatement", + "expression": { + "type": "concatenation", + "pieces": [ + { + "type": "variable", + "name": "foo" + }, + { + "type": "variable", + "name": "bar" + } + ] + }, + "control": ";", + "next": null + } +] diff --git a/tests/fixtures/shellcheck-tests/arithmetic17/ast.json b/tests/fixtures/shellcheck-tests/arithmetic17/ast.json new file mode 100644 index 0000000..4503489 --- /dev/null +++ b/tests/fixtures/shellcheck-tests/arithmetic17/ast.json @@ -0,0 +1,35 @@ +[ + { + "type": "arithmeticStatement", + "expression": { + "type": "arithmeticBinary", + "operator": "<", + "left": { + "type": "variable", + "name": "i" + }, + "right": { + "type": "arithmeticBinary", + "operator": "+", + "left": { + "type": "number", + "value": 0 + }, + "right": { + "type": "arithmeticBinary", + "operator": "+", + "left": { + "type": "number", + "value": 1 + }, + "right": { + "type": "number", + "value": 1 + } + } + } + }, + "control": ";", + "next": null + } +] diff --git a/tests/fixtures/shellcheck-tests/arithmetic18/ast.json b/tests/fixtures/shellcheck-tests/arithmetic18/ast.json new file mode 100644 index 0000000..3fea4e5 --- /dev/null +++ b/tests/fixtures/shellcheck-tests/arithmetic18/ast.json @@ -0,0 +1,22 @@ +[ + { + "type": "arithmeticStatement", + "expression": { + "type": "arithmeticConditional", + "test": { + "type": "variable", + "name": "a" + }, + "consequent": { + "type": "variable", + "name": "b" + }, + "alternate": { + "type": "variable", + "name": "c" + } + }, + "control": ";", + "next": null + } +] diff --git a/tests/fixtures/shellcheck-tests/arithmetic19/ast.json b/tests/fixtures/shellcheck-tests/arithmetic19/ast.json new file mode 100644 index 0000000..e6f3a68 --- /dev/null +++ b/tests/fixtures/shellcheck-tests/arithmetic19/ast.json @@ -0,0 +1,19 @@ +[ + { + "type": "arithmeticStatement", + "expression": { + "type": "arithmeticBinary", + "operator": "+", + "left": { + "type": "number", + "value": 3 + }, + "right": { + "type": "number", + "value": 2 + } + }, + "control": ";", + "next": null + } +] \ No newline at end of file diff --git a/tests/fixtures/shellcheck-tests/arithmetic2/ast.json b/tests/fixtures/shellcheck-tests/arithmetic2/ast.json new file mode 100644 index 0000000..a3c376a --- /dev/null +++ b/tests/fixtures/shellcheck-tests/arithmetic2/ast.json @@ -0,0 +1,36 @@ +[ + { + "type": "arithmeticStatement", + "expression": { + "type": "arithmeticBinary", + "operator": "-", + "left": { + "type": "arithmeticBinary", + "operator": "*", + "left": { + "type": "variable", + "name": "N" + }, + "right": { + "type": "number", + "value": 4 + } + }, + "right": { + "type": "arithmeticSequence", + "expressions": [ + { + "type": "number", + "value": 3 + }, + { + "type": "number", + "value": 2 + } + ] + } + }, + "control": ";", + "next": null + } +] diff --git a/tests/fixtures/shellcheck-tests/arithmetic20/ast.json b/tests/fixtures/shellcheck-tests/arithmetic20/ast.json new file mode 100644 index 0000000..1420dda --- /dev/null +++ b/tests/fixtures/shellcheck-tests/arithmetic20/ast.json @@ -0,0 +1,33 @@ +[ + { + "type": "arithmeticStatement", + "expression": { + "type": "arithmeticConditional", + "test": { + "type": "variable", + "name": "a" + }, + "consequent": { + "type": "arithmeticConditional", + "test": { + "type": "variable", + "name": "b" + }, + "consequent": { + "type": "variable", + "name": "c" + }, + "alternate": { + "type": "variable", + "name": "d" + } + }, + "alternate": { + "type": "variable", + "name": "e" + } + }, + "control": ";", + "next": null + } +] diff --git a/tests/fixtures/shellcheck-tests/arithmetic21/ast.json b/tests/fixtures/shellcheck-tests/arithmetic21/ast.json new file mode 100644 index 0000000..d8871b1 --- /dev/null +++ b/tests/fixtures/shellcheck-tests/arithmetic21/ast.json @@ -0,0 +1,33 @@ +[ + { + "type": "arithmeticStatement", + "expression": { + "type": "arithmeticConditional", + "test": { + "type": "variable", + "name": "a" + }, + "consequent": { + "type": "variable", + "name": "b" + }, + "alternate": { + "type": "arithmeticConditional", + "test": { + "type": "variable", + "name": "c" + }, + "consequent": { + "type": "variable", + "name": "d" + }, + "alternate": { + "type": "variable", + "name": "e" + } + } + }, + "control": ";", + "next": null + } +] diff --git a/tests/fixtures/shellcheck-tests/arithmetic22/ast.json b/tests/fixtures/shellcheck-tests/arithmetic22/ast.json new file mode 100644 index 0000000..81dbb95 --- /dev/null +++ b/tests/fixtures/shellcheck-tests/arithmetic22/ast.json @@ -0,0 +1,19 @@ +[ + { + "type": "arithmeticStatement", + "expression": { + "type": "arithmeticUnary", + "operator": "!", + "argument": { + "type": "arithmeticUnary", + "operator": "!", + "argument": { + "type": "variable", + "name": "a" + } + } + }, + "control": ";", + "next": null + } +] diff --git a/tests/fixtures/shellcheck-tests/arithmetic3/ast.json b/tests/fixtures/shellcheck-tests/arithmetic3/ast.json new file mode 100644 index 0000000..7895898 --- /dev/null +++ b/tests/fixtures/shellcheck-tests/arithmetic3/ast.json @@ -0,0 +1,27 @@ +[ + { + "type": "arithmeticStatement", + "expression": { + "type": "arithmeticAssignment", + "left": { + "type": "variable", + "name": "n" + }, + "operator": "|=", + "right": { + "type": "arithmeticBinary", + "operator": "<<", + "left": { + "type": "number", + "value": 2 + }, + "right": { + "type": "number", + "value": 1 + } + } + }, + "control": ";", + "next": null + } +] diff --git a/tests/fixtures/shellcheck-tests/arithmetic4/ast.json b/tests/fixtures/shellcheck-tests/arithmetic4/ast.json new file mode 100644 index 0000000..4b77d73 --- /dev/null +++ b/tests/fixtures/shellcheck-tests/arithmetic4/ast.json @@ -0,0 +1,27 @@ +[ + { + "type": "arithmeticStatement", + "expression": { + "type": "arithmeticAssignment", + "left": { + "type": "variable", + "name": "n" + }, + "operator": "&=", + "right": { + "type": "arithmeticBinary", + "operator": "**", + "left": { + "type": "number", + "value": 2 + }, + "right": { + "type": "number", + "value": 3 + } + } + }, + "control": ";", + "next": null + } +] diff --git a/tests/fixtures/shellcheck-tests/arithmetic5/.error.json b/tests/fixtures/shellcheck-tests/arithmetic5/.error.json new file mode 100644 index 0000000..66c96cc --- /dev/null +++ b/tests/fixtures/shellcheck-tests/arithmetic5/.error.json @@ -0,0 +1,3 @@ +{ + "bash_message": "attempted assignment to non-variable" +} diff --git a/tests/fixtures/shellcheck-tests/arithmetic5/ast.json b/tests/fixtures/shellcheck-tests/arithmetic5/ast.json new file mode 100644 index 0000000..c9c5935 --- /dev/null +++ b/tests/fixtures/shellcheck-tests/arithmetic5/ast.json @@ -0,0 +1,35 @@ +[ + { + "type": "arithmeticStatement", + "expression": { + "type": "arithmeticAssignment", + "left": { + "type": "number", + "value": 1 + }, + "operator": "|=", + "right": { + "type": "arithmeticAssignment", + "left": { + "type": "arithmeticLogical", + "operator": "&&", + "left": { + "type": "number", + "value": 4 + }, + "right": { + "type": "variable", + "name": "n" + } + }, + "operator": ">>=", + "right": { + "type": "number", + "value": 4 + } + } + }, + "control": ";", + "next": null + } +] diff --git a/tests/fixtures/shellcheck-tests/arithmetic6/ast.json b/tests/fixtures/shellcheck-tests/arithmetic6/ast.json new file mode 100644 index 0000000..d9936c4 --- /dev/null +++ b/tests/fixtures/shellcheck-tests/arithmetic6/ast.json @@ -0,0 +1,35 @@ +[ + { + "type": "arithmeticStatement", + "expression": { + "type": "arithmeticLogical", + "operator": "||", + "left": { + "type": "arithmeticBinary", + "operator": "|", + "left": { + "type": "number", + "value": 1 + }, + "right": { + "type": "number", + "value": 2 + } + }, + "right": { + "type": "arithmeticBinary", + "operator": "|", + "left": { + "type": "number", + "value": 3 + }, + "right": { + "type": "number", + "value": 4 + } + } + }, + "control": ";", + "next": null + } +] diff --git a/tests/fixtures/shellcheck-tests/arithmetic7/ast.json b/tests/fixtures/shellcheck-tests/arithmetic7/ast.json new file mode 100644 index 0000000..5bffb8e --- /dev/null +++ b/tests/fixtures/shellcheck-tests/arithmetic7/ast.json @@ -0,0 +1,27 @@ +[ + { + "type": "arithmeticStatement", + "expression": { + "type": "arithmeticBinary", + "operator": "*", + "left": { + "type": "number", + "value": 3 + }, + "right": { + "type": "arithmeticBinary", + "operator": "**", + "left": { + "type": "number", + "value": 2 + }, + "right": { + "type": "number", + "value": 10 + } + } + }, + "control": ";", + "next": null + } +] diff --git a/tests/fixtures/shellcheck-tests/arithmetic8/ast.json b/tests/fixtures/shellcheck-tests/arithmetic8/ast.json new file mode 100644 index 0000000..5010a8e --- /dev/null +++ b/tests/fixtures/shellcheck-tests/arithmetic8/ast.json @@ -0,0 +1,11 @@ +[ + { + "type": "arithmeticStatement", + "expression": { + "type": "number", + "value": 3 + }, + "control": ";", + "next": null + } +] diff --git a/tests/fixtures/shellcheck-tests/arithmetic9/ast.json b/tests/fixtures/shellcheck-tests/arithmetic9/ast.json new file mode 100644 index 0000000..8e9d0a7 --- /dev/null +++ b/tests/fixtures/shellcheck-tests/arithmetic9/ast.json @@ -0,0 +1,27 @@ +[ + { + "type": "arithmeticStatement", + "expression": { + "type": "arithmeticBinary", + "operator": "^", + "left": { + "type": "variable", + "name": "a" + }, + "right": { + "type": "arithmeticUnary", + "operator": "!", + "argument": { + "type": "arithmeticUnary", + "operator": "-", + "argument": { + "type": "variable", + "name": "b" + } + } + } + }, + "control": ";", + "next": null + } +] diff --git a/tests/shellcheck-fixtures.js b/tests/shellcheck-fixtures.js index 439f4cd..faa20ad 100644 --- a/tests/shellcheck-fixtures.js +++ b/tests/shellcheck-fixtures.js @@ -24,12 +24,13 @@ test('shellcheck fixtures', function(t) { t.plan(fixtureDirs.length) fixtureDirs.forEach(function (fixtureDir) { + var fixtureName = fixtureDir.replace(fixturesDir + '/', '') var source = fs.readFileSync(path.join(fixtureDir, 'source.sh'), 'utf8') var error, ast; - try { error = require(path.join(fixtureDir, 'error.json')) } catch (e) {} + try { error = require(path.resolve(fixtureDir, 'error.json')) } catch (e) {} if (!error) { - try { ast = require(path.join(fixtureDir, 'ast.json')) } catch (e) {} + try { ast = require(path.resolve(fixtureDir, 'ast.json')) } catch (e) {} } if (error) { @@ -37,15 +38,19 @@ test('shellcheck fixtures', function(t) { parse(source) }, error.message ? new RegExp(error.message) : undefined, fixtureDir + ' errored') } else if (ast) { - t.deepEqual(parse(source), ast, dir) + t.deepEqual(parse(source), ast, fixtureName) } else { try { - parse(source) - t.pass(fixtureDir.replace(fixturesDir + '/', '') + ': parsed sucessfully') + ast = parse(source) + if (process.env.write_shellcheck_fixture_ast) { + fs.writeFileSync(path.join(fixtureDir, 'ast.json'), JSON.stringify(ast, null, ' ') + '\n', 'utf8') + } + t.pass(fixtureName + ': parsed sucessfully') } catch (e) { if (e instanceof parse.SyntaxError) { - t.fail('parse failed') - formatParseError(fixtureDir, source, e) + var formattedErr = formatParseError(fixtureDir, source, e) + t.fail('parse failed: ' + formattedErr) + console.error(formattedErr + '\n' + e.stack) } else { throw e } @@ -63,5 +68,5 @@ function formatParseError (dir, source, err) { msg += '\n ' + source.slice(start, start + 10).trim() + '\n' for (var i = 0; i <= (err.column - start); i++) msg += '-'; msg += '^' - console.error(msg) + return msg }