@@ -33,6 +33,7 @@ export class SoqlParser extends CstParser {
3333 private $_aggregateFunction : any = undefined ;
3434 private $_otherFunction : any = undefined ;
3535 private $_atomicExpression : any = undefined ;
36+ private $_apexBindVariableExpression : any = undefined ;
3637 private $_arrayExpression : any = undefined ;
3738 private $_relationalOperator : any = undefined ;
3839 private $_selectClause : any = undefined ;
@@ -617,7 +618,62 @@ export class SoqlParser extends CstParser {
617618
618619 private apexBindVariableExpression = this . RULE ( 'apexBindVariableExpression' , ( ) => {
619620 this . CONSUME ( lexer . Colon ) ;
620- this . CONSUME ( lexer . Identifier ) ;
621+ // First item in list could optionally be a new instantiation
622+ this . OPTION ( ( ) => {
623+ this . SUBRULE ( this . apexBindVariableNewInstantiation , { LABEL : 'apex' } ) ;
624+ this . OPTION1 ( ( ) => {
625+ this . CONSUME ( lexer . Decimal ) ;
626+ } ) ;
627+ } ) ;
628+ // Chained function calls or nested arguments with function calls at the end
629+ this . MANY_SEP ( {
630+ SEP : lexer . Decimal ,
631+ DEF : ( ) => {
632+ this . OR (
633+ this . $_apexBindVariableExpression ||
634+ ( this . $_apexBindVariableExpression = [
635+ { ALT : ( ) => this . SUBRULE ( this . apexBindVariableFunctionCall , { LABEL : 'apex' } ) } ,
636+ { ALT : ( ) => this . CONSUME ( lexer . Identifier , { LABEL : 'apex' } ) } ,
637+ ] ) ,
638+ ) ;
639+ } ,
640+ } ) ;
641+ } ) ;
642+
643+ private apexBindVariableNewInstantiation = this . RULE ( 'apexBindVariableNewInstantiation' , ( ) => {
644+ this . CONSUME ( lexer . ApexNew , { LABEL : 'NEW' } ) ;
645+ this . CONSUME ( lexer . Identifier , { LABEL : 'FUNCTION' } ) ;
646+ this . OPTION ( ( ) => {
647+ this . SUBRULE ( this . apexBindVariableGeneric ) ;
648+ } ) ;
649+ this . SUBRULE ( this . apexBindVariableFunctionParams ) ;
650+ } ) ;
651+
652+ private apexBindVariableFunctionCall = this . RULE ( 'apexBindVariableFunctionCall' , ( ) => {
653+ this . CONSUME ( lexer . Identifier , { LABEL : 'FUNCTION' } ) ;
654+ this . SUBRULE ( this . apexBindVariableFunctionParams ) ;
655+ } ) ;
656+
657+ private apexBindVariableGeneric = this . RULE ( 'apexBindVariableGeneric' , ( ) => {
658+ this . CONSUME ( lexer . LessThan ) ;
659+ this . AT_LEAST_ONE_SEP ( {
660+ SEP : lexer . Comma ,
661+ DEF : ( ) => {
662+ this . CONSUME ( lexer . Identifier , { LABEL : 'PARAMETER' } ) ;
663+ } ,
664+ } ) ;
665+ this . CONSUME ( lexer . GreaterThan ) ;
666+ } ) ;
667+
668+ private apexBindVariableFunctionParams = this . RULE ( 'apexBindVariableFunctionParams' , ( ) => {
669+ this . CONSUME ( lexer . LParen ) ;
670+ this . MANY_SEP ( {
671+ SEP : lexer . Comma ,
672+ DEF : ( ) => {
673+ this . CONSUME ( lexer . Identifier , { LABEL : 'PARAMETER' } ) ;
674+ } ,
675+ } ) ;
676+ this . CONSUME ( lexer . RParen ) ;
621677 } ) ;
622678
623679 private arrayExpression = this . RULE ( 'arrayExpression' , ( ) => {
0 commit comments