-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
Generating Ruby target with Rule Element Labels leads to invalid Ruby code.
ifStmt : IF logicalExpression THEN ifBranchStmt+=stmt+ (ELSE elseBranchStmt+=stmt+)? END_IF ';' ;
->
invalid assignment
attr_accessor :stmt = nil
attr_accessor :ifBranchStmt = []
attr_accessor :elseBranchStmt = []
invalid overload
((IfStmtContext)_localctx).stmt = stmt()
((IfStmtContext)_localctx).ifBranchStmt.push(((IfStmtContext)_localctx).stmt);
((IfStmtContext)_localctx).stmt = stmt()
((IfStmtContext)_localctx).elseBranchStmt.push(((IfStmtContext)_localctx).stmt);
However, simply removing them manually is not enough. There is more to it. I'm investigating.
full output
class IfStmtContext < Antlr4::Runtime::ParserRuleContext
attr_accessor :stmt = nil
attr_accessor :ifBranchStmt = []
attr_accessor :elseBranchStmt = []
def IF()
return token(ExpressParser::IF, 0)
end
def logicalExpression()
return rule_context("LogicalExpressionContext",0)
end
def THEN()
return token(ExpressParser::THEN, 0)
end
def END_IF()
return token(ExpressParser::END_IF, 0)
end
def ELSE()
return token(ExpressParser::ELSE, 0)
end
def stmt()
return rule_contexts("StmtContext")
end
def stmt_i( i)
return rule_context("StmtContext",i)
end
def initialize( parent, invokingState)
super(parent, invokingState)
end
def getRuleIndex()
return RULE_ifStmt
end
def accept(visitor)
if ( visitor.respond_to?(:visitIfStmt) )
return visitor.visitIfStmt(self)
else
return visitor.visit_children(self)
end
end
end
def ifStmt()
_localctx = IfStmtContext.new(@_ctx, @_state_number)
enter_rule(_localctx, 166, RULE_ifStmt)
_la = 0
begin
enter_outer_alt(_localctx, 1)
@_state_number = 879
match(IF)
@_state_number = 880
logicalExpression()
@_state_number = 881
match(THEN)
@_state_number = 883
@_err_handler.sync(self)
_la = @_input.la(1)
loop do
@_state_number = 882
((IfStmtContext)_localctx).stmt = stmt()
((IfStmtContext)_localctx).ifBranchStmt.push(((IfStmtContext)_localctx).stmt);
@_state_number = 885
@_err_handler.sync(self)
_la = @_input.la(1)
break if (!( (((_la) & ~0x3f) == 0 && ((1 << _la) & ((1 << T__0) | (1 << ALIAS) | (1 << BEGIN_) | (1 << CASE))) != 0) || ((((_la - 71)) & ~0x3f) == 0 && ((1 << (_la - 71)) & ((1 << (ESCAPE - 71)) | (1 << (IF - 71)) | (1 << (INSERT - 71)) | (1 << (REMOVE - 71)) | (1 << (REPEAT - 71)) | (1 << (RETURN - 71)) | (1 << (SKIP_ - 71)))) != 0) || _la==SimpleId) )
end
@_state_number = 893
@_err_handler.sync(self)
_la = @_input.la(1)
if (_la==ELSE)
@_state_number = 887
match(ELSE)
@_state_number = 889
@_err_handler.sync(self)
_la = @_input.la(1)
loop do
@_state_number = 888
((IfStmtContext)_localctx).stmt = stmt()
((IfStmtContext)_localctx).elseBranchStmt.push(((IfStmtContext)_localctx).stmt);
@_state_number = 891
@_err_handler.sync(self)
_la = @_input.la(1)
break if (!( (((_la) & ~0x3f) == 0 && ((1 << _la) & ((1 << T__0) | (1 << ALIAS) | (1 << BEGIN_) | (1 << CASE))) != 0) || ((((_la - 71)) & ~0x3f) == 0 && ((1 << (_la - 71)) & ((1 << (ESCAPE - 71)) | (1 << (IF - 71)) | (1 << (INSERT - 71)) | (1 << (REMOVE - 71)) | (1 << (REPEAT - 71)) | (1 << (RETURN - 71)) | (1 << (SKIP_ - 71)))) != 0) || _la==SimpleId) )
end
end
@_state_number = 895
match(END_IF)
@_state_number = 896
match(T__0)
rescue Antlr4::Runtime::RecognitionException => re
_localctx.exception = re
@_err_handler.report_error(self, re)
@_err_handler.recover(self, re)
ensure
exit_rule()
end
return _localctx
end
Metadata
Metadata
Assignees
Labels
No labels