Skip to content
This repository has been archived by the owner on May 26, 2023. It is now read-only.

Commit

Permalink
Fix bug parse error on function parameters
Browse files Browse the repository at this point in the history
Fixes #111
  • Loading branch information
nishtahir committed Jun 17, 2018
1 parent ca077d8 commit 05ecbe6
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
Binary file modified dist/libwist.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion src/antlr/BrightScript.g4
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ baseType
;

expressionList
: traversableExpression (COMMA traversableExpression)*
: assignableExpression (COMMA assignableExpression)*
;

expression
Expand Down
20 changes: 12 additions & 8 deletions src/cpp/parser/BrightScriptParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5307,12 +5307,12 @@ BrightScriptParser::ExpressionListContext::ExpressionListContext(ParserRuleConte
: ParserRuleContext(parent, invokingState) {
}

std::vector<BrightScriptParser::TraversableExpressionContext *> BrightScriptParser::ExpressionListContext::traversableExpression() {
return getRuleContexts<BrightScriptParser::TraversableExpressionContext>();
std::vector<BrightScriptParser::AssignableExpressionContext *> BrightScriptParser::ExpressionListContext::assignableExpression() {
return getRuleContexts<BrightScriptParser::AssignableExpressionContext>();
}

BrightScriptParser::TraversableExpressionContext* BrightScriptParser::ExpressionListContext::traversableExpression(size_t i) {
return getRuleContext<BrightScriptParser::TraversableExpressionContext>(i);
BrightScriptParser::AssignableExpressionContext* BrightScriptParser::ExpressionListContext::assignableExpression(size_t i) {
return getRuleContext<BrightScriptParser::AssignableExpressionContext>(i);
}

std::vector<tree::TerminalNode *> BrightScriptParser::ExpressionListContext::COMMA() {
Expand Down Expand Up @@ -5359,15 +5359,15 @@ BrightScriptParser::ExpressionListContext* BrightScriptParser::expressionList()
try {
enterOuterAlt(_localctx, 1);
setState(713);
traversableExpression();
assignableExpression();
setState(718);
_errHandler->sync(this);
_la = _input->LA(1);
while (_la == BrightScriptParser::COMMA) {
setState(714);
match(BrightScriptParser::COMMA);
setState(715);
traversableExpression();
assignableExpression();
setState(720);
_errHandler->sync(this);
_la = _input->LA(1);
Expand Down Expand Up @@ -5901,13 +5901,15 @@ BrightScriptParser::ExpressionContext* BrightScriptParser::expression(int preced
| (1ULL << BrightScriptParser::CREATEOBJECT)
| (1ULL << BrightScriptParser::EVAL)
| (1ULL << BrightScriptParser::FALSE)
| (1ULL << BrightScriptParser::FUNCTION)
| (1ULL << BrightScriptParser::GETGLOBALAA)
| (1ULL << BrightScriptParser::GETLASTRUNCOMPILEERROR)
| (1ULL << BrightScriptParser::GETLASTRUNRUNTIMEERROR)
| (1ULL << BrightScriptParser::INVALID)
| (1ULL << BrightScriptParser::NOT)
| (1ULL << BrightScriptParser::RUN)
| (1ULL << BrightScriptParser::STRING)
| (1ULL << BrightScriptParser::SUB)
| (1ULL << BrightScriptParser::TAB)
| (1ULL << BrightScriptParser::TRUE)
| (1ULL << BrightScriptParser::TYPE)
Expand Down Expand Up @@ -6301,13 +6303,15 @@ BrightScriptParser::GlobalFunctionInvocationContext* BrightScriptParser::globalF
| (1ULL << BrightScriptParser::CREATEOBJECT)
| (1ULL << BrightScriptParser::EVAL)
| (1ULL << BrightScriptParser::FALSE)
| (1ULL << BrightScriptParser::FUNCTION)
| (1ULL << BrightScriptParser::GETGLOBALAA)
| (1ULL << BrightScriptParser::GETLASTRUNCOMPILEERROR)
| (1ULL << BrightScriptParser::GETLASTRUNRUNTIMEERROR)
| (1ULL << BrightScriptParser::INVALID)
| (1ULL << BrightScriptParser::NOT)
| (1ULL << BrightScriptParser::RUN)
| (1ULL << BrightScriptParser::STRING)
| (1ULL << BrightScriptParser::SUB)
| (1ULL << BrightScriptParser::TAB)
| (1ULL << BrightScriptParser::TRUE)
| (1ULL << BrightScriptParser::TYPE)
Expand Down Expand Up @@ -8220,8 +8224,8 @@ BrightScriptParser::Initializer::Initializer() {
0x2c6, 0x7, 0x4, 0x2, 0x2, 0x2c6, 0x2c8, 0x5, 0x54, 0x2b, 0x2, 0x2c7,
0x2c5, 0x3, 0x2, 0x2, 0x2, 0x2c7, 0x2c8, 0x3, 0x2, 0x2, 0x2, 0x2c8,
0x53, 0x3, 0x2, 0x2, 0x2, 0x2c9, 0x2ca, 0x9, 0x3, 0x2, 0x2, 0x2ca, 0x55,
0x3, 0x2, 0x2, 0x2, 0x2cb, 0x2d0, 0x5, 0x5a, 0x2e, 0x2, 0x2cc, 0x2cd,
0x7, 0x56, 0x2, 0x2, 0x2cd, 0x2cf, 0x5, 0x5a, 0x2e, 0x2, 0x2ce, 0x2cc,
0x3, 0x2, 0x2, 0x2, 0x2cb, 0x2d0, 0x5, 0x5c, 0x2f, 0x2, 0x2cc, 0x2cd,
0x7, 0x56, 0x2, 0x2, 0x2cd, 0x2cf, 0x5, 0x5c, 0x2f, 0x2, 0x2ce, 0x2cc,
0x3, 0x2, 0x2, 0x2, 0x2cf, 0x2d2, 0x3, 0x2, 0x2, 0x2, 0x2d0, 0x2ce,
0x3, 0x2, 0x2, 0x2, 0x2d0, 0x2d1, 0x3, 0x2, 0x2, 0x2, 0x2d1, 0x57, 0x3,
0x2, 0x2, 0x2, 0x2d2, 0x2d0, 0x3, 0x2, 0x2, 0x2, 0x2d3, 0x2d4, 0x8,
Expand Down
4 changes: 2 additions & 2 deletions src/cpp/parser/BrightScriptParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -992,8 +992,8 @@ class BrightScriptParser : public antlr4::Parser {
public:
ExpressionListContext(antlr4::ParserRuleContext *parent, size_t invokingState);
virtual size_t getRuleIndex() const override;
std::vector<TraversableExpressionContext *> traversableExpression();
TraversableExpressionContext* traversableExpression(size_t i);
std::vector<AssignableExpressionContext *> assignableExpression();
AssignableExpressionContext* assignableExpression(size_t i);
std::vector<antlr4::tree::TerminalNode *> COMMA();
antlr4::tree::TerminalNode* COMMA(size_t i);

Expand Down
5 changes: 5 additions & 0 deletions test/regression/111.brs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sub buOptionalTests()
res = optional.ifPresent(function(value) as Integer 'parse error
return value + 1
end function)
end sub

0 comments on commit 05ecbe6

Please sign in to comment.