var ccalcParse = (function () {
function JisonParserError(msg, hash) {
Object.defineProperty(this, 'name', {
enumerable: false,
writable: false,
value: 'JisonParserError'
});
if (msg == null) msg = '???';
Object.defineProperty(this, 'message', {
enumerable: false,
writable: true,
value: msg
});
this.hash = hash;
var stacktrace;
if (hash && hash.exception instanceof Error) {
var ex2 = hash.exception;
this.message = ex2.message || msg;
stacktrace = ex2.stack;
}
if (!stacktrace) {
if (Error.hasOwnProperty('captureStackTrace')) { Error.captureStackTrace(this, this.constructor);
} else {
stacktrace = (new Error(msg)).stack;
}
}
if (stacktrace) {
Object.defineProperty(this, 'stack', {
enumerable: false,
writable: false,
value: stacktrace
});
}
}
if (typeof Object.setPrototypeOf === 'function') {
Object.setPrototypeOf(JisonParserError.prototype, Error.prototype);
} else {
JisonParserError.prototype = Object.create(Error.prototype);
}
JisonParserError.prototype.constructor = JisonParserError;
JisonParserError.prototype.name = 'JisonParserError';
function bp(s) {
var rv = [];
var p = s.pop;
var r = s.rule;
for (var i = 0, l = p.length; i < l; i++) {
rv.push([
p[i],
r[i]
]);
}
return rv;
}
function bt(s) {
var rv = [];
var d = s.len;
var y = s.symbol;
var t = s.type;
var a = s.state;
var m = s.mode;
var g = s.goto;
for (var i = 0, l = d.length; i < l; i++) {
var n = d[i];
var q = {};
for (var j = 0; j < n; j++) {
var z = y.shift();
switch (t.shift()) {
case 2:
q[z] = [
m.shift(),
g.shift()
];
break;
case 0:
q[z] = a.shift();
break;
default:
q[z] = [
3
];
}
}
rv.push(q);
}
return rv;
}
function s(c, l, a) {
a = a || 0;
for (var i = 0; i < l; i++) {
this.push(c);
c += a;
}
}
function c(i, l) {
i = this.length - i;
for (l += i; i < l; i++) {
this.push(this[i]);
}
}
function u(a) {
var rv = [];
for (var i = 0, l = a.length; i < l; i++) {
var e = a[i];
if (typeof e === 'function') {
i++;
e.apply(rv, a[i]);
} else {
rv.push(e);
}
}
return rv;
}
var parser = {
trace: function no_op_trace() { },
JisonParserError: JisonParserError,
yy: {},
options: {
type: "lalr",
errorRecoveryTokenDiscardCount: 3
},
symbols_: {
"$accept": 0,
"$end": 1,
"ADD": 12,
"ASSIGN": 7,
"DIV": 14,
"EOF": 1,
"IDENTIFIER": 6,
"LBRACE": 9,
"MULT": 13,
"RBRACE": 10,
"SEMICOLON": 5,
"SUB": 11,
"VALUE": 15,
"error": 2,
"expression": 8,
"program": 3,
"statement": 4
},
terminals_: {
1: "EOF",
2: "error",
5: "SEMICOLON",
6: "IDENTIFIER",
7: "ASSIGN",
9: "LBRACE",
10: "RBRACE",
11: "SUB",
12: "ADD",
13: "MULT",
14: "DIV",
15: "VALUE"
},
TERROR: 2,
EOF: 1,
originalQuoteName: null,
originalParseError: null,
cleanupAfterParse: null,
constructParseErrorInfo: null,
__reentrant_call_depth: 0,
quoteName: function parser_quoteName(id_str) {
return '"' + id_str + '"';
},
describeSymbol: function parser_describeSymbol(symbol) {
if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) {
return this.terminal_descriptions_[symbol];
}
else if (symbol === this.EOF) {
return 'end of input';
}
else if (this.terminals_[symbol]) {
return this.quoteName(this.terminals_[symbol]);
}
var s = this.symbols_;
for (var key in s) {
if (s[key] === symbol) {
return key;
}
}
return null;
},
collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) {
var TERROR = this.TERROR;
var tokenset = [];
var check = {};
if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) {
return [
this.state_descriptions_[state]
];
}
for (var p in this.table[state]) {
p = +p;
if (p !== TERROR) {
var d = do_not_describe ? p : this.describeSymbol(p);
if (d && !check[d]) {
tokenset.push(d);
check[d] = true; }
}
}
return tokenset;
},
productions_: bp({
pop: u([
s,
[3, 3],
4,
4,
s,
[8, 8]
]),
rule: u([
3,
2,
4,
3,
1,
3,
2,
s,
[3, 4],
1,
1
])
}),
performAction: function parser__PerformAction(yytext, yyloc, yy, yystate , $0, $$ , _$ ) {
switch (yystate) {
case 3:
yy.parser.yyErrOk();
break;
case 4:
VarSetValue(var, $$[$0]);
break;
case 6:
this.$ = $$[$0 - 1];
break;
case 7:
this.$ = - $$[$0];
break;
case 8:
this.$ = ReduceAdd($$[$0 - 2], $$[$0], &_$[$0]);
if ( debug )
printf("reduce %lf + %lf => %lf\n", $$[$0 - 2], $$[$0], this.$);
break;
case 9:
this.$ = ReduceSub($$[$0 - 2], $$[$0], &_$[$0]);
if ( debug )
printf("reduce %lf - %lf => %lf\n", $$[$0 - 2], $$[$0], this.$);
break;
case 10:
this.$ = ReduceMult($$[$0 - 2], $$[$0], &_$[$0]);
if ( debug )
printf("reduce %lf * %lf => %lf\n", $$[$0 - 2], $$[$0], this.$);
break;
case 11:
this.$ = ReduceDiv($$[$0 - 2], $$[$0], &_$[$0]);
if ( debug )
printf("reduce %lf / %lf => %lf\n", $$[$0 - 2], $$[$0], this.$);
break;
case 12:
this.$ = $$[$0];
break;
case 13:
this.$ = VarGetValue($$[$0], &_$[$0]);
if ( debug )
printf("identifier %s => %lf\n", $$[$0], this.$);
break;
}
},
table: bt({
len: u([
7,
1,
2,
7,
6,
5,
5,
7,
8,
1,
s,
[5, 6],
7,
7,
1,
7,
6,
s,
[7, 5],
1
]),
symbol: u([
3,
4,
6,
8,
9,
11,
15,
1,
2,
5,
2,
5,
7,
s,
[11, 4, 1],
2,
5,
c,
[6, 4],
c,
[21, 5],
c,
[5, 5],
2,
5,
s,
[10, 5, 1],
1,
c,
[41, 7],
5,
c,
[26, 10],
c,
[5, 15],
c,
[39, 5],
c,
[46, 7],
c,
[53, 15],
c,
[84, 6],
c,
[28, 14],
c,
[7, 21],
1
]),
type: u([
0,
0,
2,
0,
s,
[2, 3],
1,
s,
[2, 16],
c,
[21, 4],
c,
[5, 6],
c,
[17, 8],
c,
[41, 6],
c,
[26, 12],
c,
[5, 15],
s,
[2, 19],
c,
[53, 9],
s,
[2, 40]
]),
state: u([
1,
2,
4,
15,
17,
18,
2,
4,
s,
[20, 5, 1],
26,
2,
4
]),
mode: u([
s,
[1, 6],
2,
2,
c,
[3, 3],
s,
[2, 4],
s,
[1, 12],
s,
[2, 8],
s,
[1, 30],
s,
[2, 15],
c,
[78, 7],
c,
[25, 8],
c,
[7, 14],
s,
[2, 17]
]),
goto: u([
3,
5,
6,
7,
9,
8,
13,
13,
10,
s,
[13, 4],
5,
5,
12,
11,
13,
14,
16,
c,
[19, 3],
c,
[4, 4],
s,
[12, 7],
2,
c,
[35, 4],
19,
c,
[21, 8],
c,
[4, 12],
25,
c,
[46, 4],
s,
[13, 7],
s,
[7, 7],
1,
c,
[45, 4],
4,
4,
c,
[25, 4],
s,
[8, 5],
13,
14,
s,
[9, 5],
13,
14,
s,
[10, 7],
s,
[11, 7],
s,
[6, 7],
3
])
}),
defaultActions: {
18: 1,
26: 3
},
parseError: function parseError(str, hash) {
if (hash.recoverable) {
this.trace(str);
hash.destroy(); } else {
throw new this.JisonParserError(str, hash);
}
},
parse: function parse(input) {
var self = this,
stack = new Array(128), sstack = new Array(128),
vstack = new Array(128), lstack = new Array(128), table = this.table,
sp = 0;
var recovering = 0; var TERROR = this.TERROR,
EOF = this.EOF,
ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3;
var NO_ACTION = [0, table.length ];
var lexer;
if (this.__lexer__) {
lexer = this.__lexer__;
} else {
lexer = this.__lexer__ = Object.create(this.lexer);
}
var sharedState = {
yy: {
parseError: null,
quoteName: null,
lexer: null,
parser: null,
pre_parse: null,
post_parse: null
}
};
for (var k in this.yy) {
if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
sharedState.yy[k] = this.yy[k];
}
}
sharedState.yy.lexer = lexer;
sharedState.yy.parser = this;
if (this.yyErrOk === 1) {
this.yyErrOk = function yyErrOk() {
recovering = 0;
};
}
lexer.setInput(input, sharedState.yy);
if (typeof lexer.yylloc === 'undefined') {
lexer.yylloc = {};
}
var yyloc = lexer.yylloc;
lstack[sp] = yyloc;
vstack[sp] = null;
sstack[sp] = 0;
stack[sp] = 0;
++sp;
if (typeof lexer.yytext === 'undefined') {
lexer.yytext = '';
}
var yytext = lexer.yytext;
if (typeof lexer.yylineno === 'undefined') {
lexer.yylineno = 0;
}
var ranges = lexer.options && lexer.options.ranges;
if (typeof sharedState.yy.parseError === 'function') {
this.parseError = sharedState.yy.parseError;
} else {
this.parseError = this.originalParseError;
}
if (typeof sharedState.yy.quoteName === 'function') {
this.quoteName = sharedState.yy.quoteName;
} else {
this.quoteName = this.originalQuoteName;
}
this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods) {
var rv;
if (invoke_post_methods) {
if (sharedState.yy.post_parse) {
rv = sharedState.yy.post_parse.call(this, sharedState.yy, resultValue);
if (typeof rv !== 'undefined') resultValue = rv;
}
if (this.post_parse) {
rv = this.post_parse.call(this, sharedState.yy, resultValue);
if (typeof rv !== 'undefined') resultValue = rv;
}
}
if (this.__reentrant_call_depth > 1) return resultValue;
if (sharedState.yy) {
sharedState.yy.parseError = undefined;
sharedState.yy.quoteName = undefined;
sharedState.yy.lexer = undefined;
sharedState.yy.parser = undefined;
if (lexer.yy === sharedState.yy) {
lexer.yy = undefined;
}
}
sharedState.yy = undefined;
this.parseError = this.originalParseError;
this.quoteName = this.originalQuoteName;
stack.length = 0; sstack.length = 0;
lstack.length = 0;
vstack.length = 0;
stack_pointer = 0;
return resultValue;
};
this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) {
return {
errStr: msg,
exception: ex,
text: lexer.match,
value: lexer.yytext,
token: this.describeSymbol(symbol) || symbol,
token_id: symbol,
line: lexer.yylineno,
loc: lexer.yylloc,
expected: expected,
recoverable: recoverable,
state: state,
action: action,
new_state: newState,
symbol_stack: stack,
state_stack: sstack,
value_stack: vstack,
location_stack: lstack,
stack_pointer: sp,
yy: sharedState.yy,
lexer: lexer,
destroy: function destructParseErrorInfo() {
var rec = !!this.recoverable;
for (var key in this) {
if (this.hasOwnProperty(key) && typeof key !== 'function') {
this[key] = undefined;
}
}
this.recoverable = rec;
}
};
};
function lex() {
var token = lexer.lex();
if (typeof token !== 'number') {
token = self.symbols_[token] || token;
}
return token || EOF;
}
var symbol = 0;
var preErrorSymbol = 0;
var state, action, r, t;
var yyval = {};
var p, len, this_production;
var lstack_begin, lstack_end;
var newState;
var retval = false;
function locateNearestErrorRecoveryRule(state) {
var stack_probe = sp - 1;
var depth = 0;
for (;;) {
var t = table[state][TERROR] || NO_ACTION;
if (t[0]) {
return depth;
}
if (state === 0 || stack_probe < 1) {
return -1; }
--stack_probe; state = sstack[stack_probe];
++depth;
}
}
try {
this.__reentrant_call_depth++;
if (this.pre_parse) {
this.pre_parse.call(this, sharedState.yy);
}
if (sharedState.yy.pre_parse) {
sharedState.yy.pre_parse.call(this, sharedState.yy);
}
newState = sstack[sp - 1];
for (;;) {
state = newState;
if (this.defaultActions[state]) {
action = 2;
newState = this.defaultActions[state];
} else {
if (!symbol) {
symbol = lex();
}
t = (table[state] && table[state][symbol]) || NO_ACTION;
newState = t[1];
action = t[0];
if (!action) {
var error_rule_depth = locateNearestErrorRecoveryRule(state);
var errStr = null;
var errSymbolDescr = (this.describeSymbol(symbol) || symbol);
var expected = this.collect_expected_token_set(state);
if (!recovering) {
if (lexer.showPosition) {
errStr = 'Parse error on line ' + (lexer.yylineno + 1) + ':\n' + lexer.showPosition(79 - 10, 10) + '\n';
} else {
errStr = 'Parse error on line ' + (lexer.yylineno + 1) + ': ';
}
if (expected.length) {
errStr += 'Expecting ' + expected.join(', ') + ', got unexpected ' + errSymbolDescr;
} else {
errStr += 'Unexpected ' + errSymbolDescr;
}
p = this.constructParseErrorInfo(errStr, null, expected, (error_rule_depth >= 0));
r = this.parseError(p.errStr, p);
if (!p.recoverable) {
retval = r;
break;
} else {
}
}
if (recovering === ERROR_RECOVERY_TOKEN_DISCARD_COUNT && error_rule_depth >= 0) {
if (symbol === EOF || preErrorSymbol === EOF) {
p = this.constructParseErrorInfo((errStr || 'Parsing halted while starting to recover from another error.'), null, expected, false);
retval = this.parseError(p.errStr, p);
break;
}
yytext = lexer.yytext;
yyloc = lexer.yylloc;
symbol = lex();
}
if (error_rule_depth < 0) {
p = this.constructParseErrorInfo((errStr || 'Parsing halted. No suitable error recovery rule available.'), null, expected, false);
retval = this.parseError(p.errStr, p);
break;
}
sp -= error_rule_depth;
preErrorSymbol = (symbol === TERROR ? 0 : symbol); symbol = TERROR; recovering = ERROR_RECOVERY_TOKEN_DISCARD_COUNT;
newState = sstack[sp - 1];
continue;
}
}
switch (action) {
default:
if (action instanceof Array) {
p = this.constructParseErrorInfo(('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol), null, null, false);
retval = this.parseError(p.errStr, p);
break;
}
p = this.constructParseErrorInfo('Parsing halted. No viable error recovery approach available due to internal system failure.', null, null, false);
retval = this.parseError(p.errStr, p);
break;
case 1:
stack[sp] = symbol;
vstack[sp] = lexer.yytext;
lstack[sp] = lexer.yylloc;
sstack[sp] = newState; ++sp;
symbol = 0;
if (!preErrorSymbol) {
yytext = lexer.yytext;
yyloc = lexer.yylloc;
if (recovering > 0) {
recovering--;
}
} else {
symbol = preErrorSymbol;
preErrorSymbol = 0;
t = (table[newState] && table[newState][symbol]) || NO_ACTION;
if (!t[0]) {
symbol = 0;
}
}
continue;
case 2:
this_production = this.productions_[newState - 1]; len = this_production[1];
lstack_end = sp;
lstack_begin = lstack_end - (len || 1);
lstack_end--;
vstack[sp] = undefined;
yyval.$ = vstack[sp - len];
yyval._$ = {
first_line: lstack[lstack_begin].first_line,
last_line: lstack[lstack_end].last_line,
first_column: lstack[lstack_begin].first_column,
last_column: lstack[lstack_end].last_column
};
if (ranges) {
yyval._$.range = [lstack[lstack_begin].range[0], lstack[lstack_end].range[1]];
}
r = this.performAction.call(yyval, yytext, yyloc, sharedState.yy, newState, sp - 1, vstack, lstack);
if (typeof r !== 'undefined') {
retval = r;
break;
}
sp -= len;
var ntsymbol = this_production[0]; stack[sp] = ntsymbol;
vstack[sp] = yyval.$;
lstack[sp] = yyval._$;
newState = table[sstack[sp - 1]][ntsymbol];
sstack[sp] = newState;
++sp;
continue;
case 3:
retval = true;
if (typeof yyval.$ !== 'undefined') {
retval = yyval.$;
}
break;
}
break;
}
} catch (ex) {
p = this.constructParseErrorInfo('Parsing aborted due to exception.', ex, null, false);
retval = this.parseError(p.errStr, p);
} finally {
retval = this.cleanupAfterParse(retval, true);
this.__reentrant_call_depth--;
}
return retval;
},
yyErrOk: 1
};
parser.originalParseError = parser.parseError;
parser.originalQuoteName = parser.quoteName;
static Variable *var;
var lexer = (function () {
function JisonLexerError(msg, hash) {
Object.defineProperty(this, 'name', {
enumerable: false,
writable: false,
value: 'JisonLexerError'
});
if (msg == null) msg = '???';
Object.defineProperty(this, 'message', {
enumerable: false,
writable: true,
value: msg
});
this.hash = hash;
var stacktrace;
if (hash && hash.exception instanceof Error) {
var ex2 = hash.exception;
this.message = ex2.message || msg;
stacktrace = ex2.stack;
}
if (!stacktrace) {
if (Error.hasOwnProperty('captureStackTrace')) { Error.captureStackTrace(this, this.constructor);
} else {
stacktrace = (new Error(msg)).stack;
}
}
if (stacktrace) {
Object.defineProperty(this, 'stack', {
enumerable: false,
writable: false,
value: stacktrace
});
}
}
if (typeof Object.setPrototypeOf === 'function') {
Object.setPrototypeOf(JisonLexerError.prototype, Error.prototype);
} else {
JisonLexerError.prototype = Object.create(Error.prototype);
}
JisonLexerError.prototype.constructor = JisonLexerError;
JisonLexerError.prototype.name = 'JisonLexerError';
var lexer = {
EOF: 1,
ERROR: 2,
__currentRuleSet__: null,
parseError: function lexer_parseError(str, hash) {
if (this.yy.parser && typeof this.yy.parser.parseError === 'function') {
return this.yy.parser.parseError(str, hash) || this.ERROR;
} else {
throw new this.JisonLexerError(str);
}
},
clear: function lexer_clear() {
this.yytext = '';
this.yyleng = 0;
this.match = '';
this.matches = false;
this._more = false;
this._backtrack = false;
},
setInput: function lexer_setInput(input, yy) {
this.yy = yy || this.yy || {};
this._input = input;
this.clear();
this._signaled_error_token = this.done = false;
this.yylineno = 0;
this.matched = '';
this.conditionStack = ['INITIAL'];
this.__currentRuleSet__ = null;
this.yylloc = {
first_line: 1,
first_column: 0,
last_line: 1,
last_column: 0
};
if (this.options.ranges) {
this.yylloc.range = [0, 0];
}
this.offset = 0;
return this;
},
input: function lexer_input() {
if (!this._input) {
this.done = true;
return null;
}
var ch = this._input[0];
this.yytext += ch;
this.yyleng++;
this.offset++;
this.match += ch;
this.matched += ch;
var slice_len = 1;
var lines = false;
if (ch === '\n') {
lines = true;
} else if (ch === '\r') {
lines = true;
var ch2 = this._input[1];
if (ch2 === '\n') {
slice_len++;
ch += ch2;
this.yytext += ch2;
this.yyleng++;
this.offset++;
this.match += ch2;
this.matched += ch2;
if (this.options.ranges) {
this.yylloc.range[1]++;
}
}
}
if (lines) {
this.yylineno++;
this.yylloc.last_line++;
} else {
this.yylloc.last_column++;
}
if (this.options.ranges) {
this.yylloc.range[1]++;
}
this._input = this._input.slice(slice_len);
return ch;
},
unput: function lexer_unput(ch) {
var len = ch.length;
var lines = ch.split(/(?:\r\n?|\n)/g);
this._input = ch + this._input;
this.yytext = this.yytext.substr(0, this.yytext.length - len);
this.offset -= len;
var oldLines = this.match.split(/(?:\r\n?|\n)/g);
this.match = this.match.substr(0, this.match.length - len);
this.matched = this.matched.substr(0, this.matched.length - len);
if (lines.length - 1) {
this.yylineno -= lines.length - 1;
}
this.yylloc.last_line = this.yylineno + 1;
this.yylloc.last_column = (lines ?
(lines.length === oldLines.length ? this.yylloc.first_column : 0)
+ oldLines[oldLines.length - lines.length].length - lines[0].length :
this.yylloc.first_column - len);
if (this.options.ranges) {
this.yylloc.range[1] = this.yylloc.range[0] + this.yyleng - len;
}
this.yyleng = this.yytext.length;
this.done = false;
return this;
},
more: function lexer_more() {
this._more = true;
return this;
},
reject: function lexer_reject() {
if (this.options.backtrack_lexer) {
this._backtrack = true;
} else {
this._signaled_error_token = (this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + this.showPosition(), {
text: this.match,
token: null,
line: this.yylineno,
loc: this.yylloc,
lexer: this
}) || this.ERROR);
}
return this;
},
less: function lexer_less(n) {
return this.unput(this.match.slice(n));
},
pastInput: function lexer_pastInput(maxSize, maxLines) {
var past = this.matched.substring(0, this.matched.length - this.match.length);
if (maxSize < 0)
maxSize = past.length;
else if (!maxSize)
maxSize = 20;
if (maxLines < 0)
maxLines = past.length; else if (!maxLines)
maxLines = 1;
past = past.substr(-maxSize * 2 - 2);
var a = past.replace(/\r\n|\r/g, '\n').split('\n');
a = a.slice(-maxLines);
past = a.join('\n');
if (past.length > maxSize) {
past = '...' + past.substr(-maxSize);
}
return past;
},
upcomingInput: function lexer_upcomingInput(maxSize, maxLines) {
var next = this.match;
if (maxSize < 0)
maxSize = next.length + this._input.length;
else if (!maxSize)
maxSize = 20;
if (maxLines < 0)
maxLines = maxSize; else if (!maxLines)
maxLines = 1;
if (next.length < maxSize * 2 + 2) {
next += this._input.substring(0, maxSize * 2 + 2); }
var a = next.replace(/\r\n|\r/g, '\n').split('\n');
a = a.slice(0, maxLines);
next = a.join('\n');
if (next.length > maxSize) {
next = next.substring(0, maxSize) + '...';
}
return next;
},
showPosition: function lexer_showPosition(maxPrefix, maxPostfix) {
var pre = this.pastInput(maxPrefix).replace(/\s/g, ' ');
var c = new Array(pre.length + 1).join('-');
return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^';
},
describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) {
var l1 = yylloc.first_line;
var l2 = yylloc.last_line;
var o1 = yylloc.first_column;
var o2 = yylloc.last_column - 1;
var dl = l2 - l1;
var d_o = (dl === 0 ? o2 - o1 : 1000);
var rv;
if (dl === 0) {
rv = 'line ' + l1 + ', ';
if (d_o === 0) {
rv += 'column ' + o1;
} else {
rv += 'columns ' + o1 + ' .. ' + o2;
}
} else {
rv = 'lines ' + l1 + '(column ' + o1 + ') .. ' + l2 + '(column ' + o2 + ')';
}
if (yylloc.range && display_range_too) {
var r1 = yylloc.range[0];
var r2 = yylloc.range[1] - 1;
if (r2 === r1) {
rv += ' {String Offset: ' + r1 + '}';
} else {
rv += ' {String Offset range: ' + r1 + ' .. ' + r2 + '}';
}
}
return rv;
},
test_match: function lexer_test_match(match, indexed_rule) {
var token,
lines,
backup,
match_str;
if (this.options.backtrack_lexer) {
backup = {
yylineno: this.yylineno,
yylloc: {
first_line: this.yylloc.first_line,
last_line: this.last_line,
first_column: this.yylloc.first_column,
last_column: this.yylloc.last_column
},
yytext: this.yytext,
match: this.match,
matches: this.matches,
matched: this.matched,
yyleng: this.yyleng,
offset: this.offset,
_more: this._more,
_input: this._input,
yy: this.yy,
conditionStack: this.conditionStack.slice(0),
done: this.done
};
if (this.options.ranges) {
backup.yylloc.range = this.yylloc.range.slice(0);
}
}
match_str = match[0];
lines = match_str.match(/(?:\r\n?|\n).*/g);
if (lines) {
this.yylineno += lines.length;
}
this.yylloc = {
first_line: this.yylloc.last_line,
last_line: this.yylineno + 1,
first_column: this.yylloc.last_column,
last_column: lines ?
lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length :
this.yylloc.last_column + match_str.length
};
this.yytext += match_str;
this.match += match_str;
this.matches = match;
this.yyleng = this.yytext.length;
if (this.options.ranges) {
this.yylloc.range = [this.offset, this.offset + this.yyleng];
}
this.offset += match_str.length;
this._more = false;
this._backtrack = false;
this._input = this._input.slice(match_str.length);
this.matched += match_str;
token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
if (this.done && this._input) {
this.done = false;
}
if (token) {
return token;
} else if (this._backtrack) {
for (var k in backup) {
this[k] = backup[k];
}
this.__currentRuleSet__ = null;
return false; } else if (this._signaled_error_token) {
token = this._signaled_error_token;
this._signaled_error_token = false;
return token;
}
return false;
},
next: function lexer_next() {
if (this.done) {
this.clear();
return this.EOF;
}
if (!this._input) {
this.done = true;
}
var token,
match,
tempMatch,
index;
if (!this._more) {
this.clear();
}
var rules = this.__currentRuleSet__;
if (!rules) {
rules = this.__currentRuleSet__ = this._currentRules();
}
for (var i = 0, len = rules.length; i < len; i++) {
tempMatch = this._input.match(this.rules[rules[i]]);
if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
match = tempMatch;
index = i;
if (this.options.backtrack_lexer) {
token = this.test_match(tempMatch, rules[i]);
if (token !== false) {
return token;
} else if (this._backtrack) {
match = undefined;
continue; } else {
return false;
}
} else if (!this.options.flex) {
break;
}
}
}
if (match) {
token = this.test_match(match, rules[index]);
if (token !== false) {
return token;
}
return false;
}
if (this._input === '') {
this.clear();
this.done = true;
return this.EOF;
} else {
token = this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), {
text: this.match + this._input,
token: null,
line: this.yylineno,
loc: this.yylloc,
lexer: this
}) || this.ERROR;
if (token === this.ERROR) {
if (!this.match.length) {
this.input();
}
}
return token;
}
},
lex: function lexer_lex() {
var r;
if (typeof this.options.pre_lex === 'function') {
r = this.options.pre_lex.call(this);
}
while (!r) {
r = this.next();
}
if (typeof this.options.post_lex === 'function') {
r = this.options.post_lex.call(this, r) || r;
}
return r;
},
begin: function lexer_begin(condition) {
return this.pushState(condition);
},
pushState: function lexer_pushState(condition) {
this.conditionStack.push(condition);
this.__currentRuleSet__ = null;
return this;
},
popState: function lexer_popState() {
var n = this.conditionStack.length - 1;
if (n > 0) {
this.__currentRuleSet__ = null;
return this.conditionStack.pop();
} else {
return this.conditionStack[0];
}
},
topState: function lexer_topState(n) {
n = this.conditionStack.length - 1 - Math.abs(n || 0);
if (n >= 0) {
return this.conditionStack[n];
} else {
return 'INITIAL';
}
},
_currentRules: function lexer__currentRules() {
if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
} else {
return this.conditions['INITIAL'].rules;
}
},
stateStackSize: function lexer_stateStackSize() {
return this.conditionStack.length;
},
options: {},
JisonLexerError: JisonLexerError,
performAction: function lexer__performAction(yy, yy_, $avoiding_name_collisions, YY_START) {
var YYSTATE = YY_START;
switch($avoiding_name_collisions) {
case 0 :
BeginToken(yy_.yytext);
break;
case 1 :
BeginToken(yy_.yytext);
yylval.value = atof(yy_.yytext);
return VALUE;
break;
case 2 :
BeginToken(yy_.yytext);
yylval.value = atof(yy_.yytext);
return VALUE;
break;
case 3 :
BeginToken(yy_.yytext);
yylval.value = atof(yy_.yytext);
return VALUE;
break;
case 4 :
BeginToken(yy_.yytext);
yylval.value = atof(yy_.yytext);
return VALUE;
break;
case 5 :
BeginToken(yy_.yytext);
yylval.string = malloc(strlen(yy_.yytext)+1);
strcpy(yylval.string, yy_.yytext);
return IDENTIFIER;
break;
case 6 :
BeginToken(yy_.yytext); return ADD;
break;
case 7 :
BeginToken(yy_.yytext); return SUB;
break;
case 8 :
BeginToken(yy_.yytext); return MULT;
break;
case 9 :
BeginToken(yy_.yytext); return DIV;
break;
case 10 :
BeginToken(yy_.yytext); return LBRACE;
break;
case 11 :
BeginToken(yy_.yytext); return RBRACE;
break;
case 12 :
BeginToken(yy_.yytext); return SEMICOLON;
break;
case 13 :
BeginToken(yy_.yytext); return ASSIGN;
break;
case 14 :
BeginToken(yy_.yytext);
return yy_.yytext[0];
break;
default:
return this.simpleCaseActionClusters[$avoiding_name_collisions];
}
},
simpleCaseActionClusters: {
},
rules: [
/^(?:[ \t\r\n]+)/,
/^(?:([0-9])+)/,
/^(?:([0-9])+\.([0-9])*)/,
/^(?:([0-9])+[Ee]["+]?([0-9])*)/,
/^(?:([0-9])+\.([0-9])*[Ee]["+]?([0-9])*)/,
/^(?:([A-Z_a-z][0-9A-Z_a-z]*))/,
/^(?:\+)/,
/^(?:-)/,
/^(?:\*)/,
/^(?:\/)/,
/^(?:\()/,
/^(?:\))/,
/^(?:;)/,
/^(?:=)/,
/^(?:.)/
],
conditions: {
"INITIAL": {
rules: [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14
],
inclusive: true
}
}
};
;
return lexer;
})();
parser.lexer = lexer;
function Parser() {
this.yy = {};
}
Parser.prototype = parser;
parser.Parser = Parser;
return new Parser();
})();
if (typeof require !== 'undefined' && typeof exports !== 'undefined') {
exports.parser = ccalcParse;
exports.Parser = ccalcParse.Parser;
exports.parse = function () {
return ccalcParse.parse.apply(ccalcParse, arguments);
};
}