From 9bf4d3556230e118c9203eeb685c92ab710e4585 Mon Sep 17 00:00:00 2001 From: ascandone Date: Wed, 27 Nov 2024 15:49:07 +0100 Subject: [PATCH] fix --- Numscript.g4 | 3 ++- internal/parser/antlr/numscript_parser.go | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Numscript.g4 b/Numscript.g4 index 2a33813..4ea640b 100644 --- a/Numscript.g4 +++ b/Numscript.g4 @@ -60,7 +60,8 @@ valueExpr: | left = valueExpr op = ('+' | '-') right = valueExpr # infixExpr; functionCallArgs: valueExpr ( COMMA valueExpr)*; -functionCall: (OVERDRAFT | IDENTIFIER) LPARENS functionCallArgs? RPARENS; +functionCall: + fnName = (OVERDRAFT | IDENTIFIER) LPARENS functionCallArgs? RPARENS; varOrigin: EQ functionCall; varDeclaration: diff --git a/internal/parser/antlr/numscript_parser.go b/internal/parser/antlr/numscript_parser.go index 3c6bcfa..542cd8b 100644 --- a/internal/parser/antlr/numscript_parser.go +++ b/internal/parser/antlr/numscript_parser.go @@ -1385,6 +1385,12 @@ type IFunctionCallContext interface { // GetParser returns the parser. GetParser() antlr.Parser + // GetFnName returns the fnName token. + GetFnName() antlr.Token + + // SetFnName sets the fnName token. + SetFnName(antlr.Token) + // Getter signatures LPARENS() antlr.TerminalNode RPARENS() antlr.TerminalNode @@ -1399,6 +1405,7 @@ type IFunctionCallContext interface { type FunctionCallContext struct { antlr.BaseParserRuleContext parser antlr.Parser + fnName antlr.Token } func NewEmptyFunctionCallContext() *FunctionCallContext { @@ -1428,6 +1435,10 @@ func NewFunctionCallContext(parser antlr.Parser, parent antlr.ParserRuleContext, func (s *FunctionCallContext) GetParser() antlr.Parser { return s.parser } +func (s *FunctionCallContext) GetFnName() antlr.Token { return s.fnName } + +func (s *FunctionCallContext) SetFnName(v antlr.Token) { s.fnName = v } + func (s *FunctionCallContext) LPARENS() antlr.TerminalNode { return s.GetToken(NumscriptParserLPARENS, 0) } @@ -1488,10 +1499,17 @@ func (p *NumscriptParser) FunctionCall() (localctx IFunctionCallContext) { p.EnterOuterAlt(localctx, 1) { p.SetState(73) + + var _lt = p.GetTokenStream().LT(1) + + localctx.(*FunctionCallContext).fnName = _lt + _la = p.GetTokenStream().LA(1) if !(_la == NumscriptParserOVERDRAFT || _la == NumscriptParserIDENTIFIER) { - p.GetErrorHandler().RecoverInline(p) + var _ri = p.GetErrorHandler().RecoverInline(p) + + localctx.(*FunctionCallContext).fnName = _ri } else { p.GetErrorHandler().ReportMatch(p) p.Consume()