Skip to content

Commit

Permalink
Support for nullary functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
silentmatt committed Jul 18, 2011
1 parent ecfc80d commit 64494d5
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,14 +435,15 @@ var Parser = (function (scope) {
PI: Math.PI
};

var PRIMARY = 1 << 0;
var OPERATOR = 1 << 1;
var FUNCTION = 1 << 2;
var LPAREN = 1 << 3;
var RPAREN = 1 << 4;
var COMMA = 1 << 5;
var SIGN = 1 << 6;
var CALL = 1 << 7;
var PRIMARY = 1 << 0;
var OPERATOR = 1 << 1;
var FUNCTION = 1 << 2;
var LPAREN = 1 << 3;
var RPAREN = 1 << 4;
var COMMA = 1 << 5;
var SIGN = 1 << 6;
var CALL = 1 << 7;
var NULLARY_CALL = 1 << 8;

Parser.prototype = {
parse: function (expr) {
Expand Down Expand Up @@ -509,10 +510,14 @@ var Parser = (function (scope) {
this.addfunc(tokenstack, operstack, TFUNCALL);
}

expected = (PRIMARY | LPAREN | FUNCTION | SIGN);
expected = (PRIMARY | LPAREN | FUNCTION | SIGN | NULLARY_CALL);
}
else if (this.isRightParenth()) {
if ((expected & RPAREN) === 0) {
if (expected & NULLARY_CALL) {
var token = new Token(TNUMBER, 0, 0, []);
tokenstack.push(token);
}
else if ((expected & RPAREN) === 0) {
this.error_parsing(this.pos, "unexpected \")\"");
}

Expand Down

0 comments on commit 64494d5

Please sign in to comment.