-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #229. Throws syntax error for empty functions and doesnt block … #230
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1986,6 +1986,11 @@ Parser.prototype = function() { | |
functionText = tokenStream.token().value; | ||
this._readWhitespace(); | ||
expr = this._expr(true); | ||
if (expr === null) { | ||
// the FUNCTION is set if there's a ( . It doesn't check for a closing ) in identOrFunctionToken in TokenStream.. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a bit confusingly worded. Perhaps this: "The FUNCTION token has already checked that there is an opening (." Or omit this line of comment entirely. The level of commenting in the line below is normal for other similar situations in the codebase. |
||
// if there's nothing between the brackets, expr is null | ||
throw new SyntaxError("Expected an expression in the function on line " + tokenStream.token().startLine + ", col " + tokenStream.token().startCol + ".", tokenStream.token().startLine, tokenStream.token().startCol); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You don't need to emit the line number message yourself; all the other SyntaxErrors in this code just pass them as the second and third arguments. Following that practice will simplify this line a lot. |
||
} | ||
functionText += expr; | ||
|
||
// START: Horrible hack in case it's an IE filter | ||
|
@@ -2009,7 +2014,7 @@ Parser.prototype = function() { | |
|
||
//functionText += this._term(); | ||
lt = tokenStream.peek(); | ||
while (lt !== Tokens.COMMA && lt !== Tokens.S && lt !== Tokens.RPAREN) { | ||
while (lt !== Tokens.COMMA && lt !== Tokens.S && lt !== Tokens.RPAREN && lt !== Tokens.EOF) { | ||
tokenStream.get(); | ||
functionText += tokenStream.token().value; | ||
lt = tokenStream.peek(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could remove this, and only go with the proposed fix in the while-loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't help you here. I'm not so much familiar with the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nschonni , do you have a preference on how to proceed? The list of dependent packages of parserlib is at https://www.npmjs.com/browse/depended/parserlib , so that's not too many.