@@ -633,33 +633,40 @@ export class SoqlParser extends CstParser {
633633 this . $_apexBindVariableExpression ||
634634 ( this . $_apexBindVariableExpression = [
635635 { ALT : ( ) => this . SUBRULE ( this . apexBindVariableFunctionCall , { LABEL : 'apex' } ) } ,
636- { ALT : ( ) => this . CONSUME ( lexer . Identifier , { LABEL : 'apex' } ) } ,
636+ { ALT : ( ) => this . SUBRULE ( this . apexBindVariableIdentifier , { LABEL : 'apex' } ) } ,
637637 ] ) ,
638638 ) ;
639639 } ,
640640 } ) ;
641641 } ) ;
642642
643+ private apexBindVariableIdentifier = this . RULE ( 'apexBindVariableIdentifier' , ( ) => {
644+ this . CONSUME ( lexer . Identifier ) ;
645+ this . OPTION ( ( ) => this . SUBRULE ( this . apexBindVariableFunctionArrayAccessor ) ) ;
646+ } ) ;
647+
643648 private apexBindVariableNewInstantiation = this . RULE ( 'apexBindVariableNewInstantiation' , ( ) => {
644- this . CONSUME ( lexer . ApexNew , { LABEL : 'NEW ' } ) ;
645- this . CONSUME ( lexer . Identifier , { LABEL : 'FUNCTION ' } ) ;
649+ this . CONSUME ( lexer . ApexNew , { LABEL : 'new ' } ) ;
650+ this . CONSUME ( lexer . Identifier , { LABEL : 'function ' } ) ;
646651 this . OPTION ( ( ) => {
647652 this . SUBRULE ( this . apexBindVariableGeneric ) ;
648653 } ) ;
649654 this . SUBRULE ( this . apexBindVariableFunctionParams ) ;
655+ this . OPTION1 ( ( ) => this . SUBRULE ( this . apexBindVariableFunctionArrayAccessor ) ) ;
650656 } ) ;
651657
652658 private apexBindVariableFunctionCall = this . RULE ( 'apexBindVariableFunctionCall' , ( ) => {
653- this . CONSUME ( lexer . Identifier , { LABEL : 'FUNCTION ' } ) ;
659+ this . CONSUME ( lexer . Identifier , { LABEL : 'function ' } ) ;
654660 this . SUBRULE ( this . apexBindVariableFunctionParams ) ;
661+ this . OPTION ( ( ) => this . SUBRULE ( this . apexBindVariableFunctionArrayAccessor ) ) ;
655662 } ) ;
656663
657664 private apexBindVariableGeneric = this . RULE ( 'apexBindVariableGeneric' , ( ) => {
658665 this . CONSUME ( lexer . LessThan ) ;
659666 this . AT_LEAST_ONE_SEP ( {
660667 SEP : lexer . Comma ,
661668 DEF : ( ) => {
662- this . CONSUME ( lexer . Identifier , { LABEL : 'PARAMETER ' } ) ;
669+ this . CONSUME ( lexer . Identifier , { LABEL : 'parameter ' } ) ;
663670 } ,
664671 } ) ;
665672 this . CONSUME ( lexer . GreaterThan ) ;
@@ -670,12 +677,22 @@ export class SoqlParser extends CstParser {
670677 this . MANY_SEP ( {
671678 SEP : lexer . Comma ,
672679 DEF : ( ) => {
673- this . CONSUME ( lexer . Identifier , { LABEL : 'PARAMETER ' } ) ;
680+ this . CONSUME ( lexer . Identifier , { LABEL : 'parameter ' } ) ;
674681 } ,
675682 } ) ;
676683 this . CONSUME ( lexer . RParen ) ;
677684 } ) ;
678685
686+ // foo[3] or foo[somIntVariable]
687+ private apexBindVariableFunctionArrayAccessor = this . RULE ( 'apexBindVariableFunctionArrayAccessor' , ( ) => {
688+ this . CONSUME ( lexer . LSquareBracket ) ;
689+ this . OR ( [
690+ { ALT : ( ) => this . CONSUME ( lexer . UnsignedInteger , { LABEL : 'value' } ) } ,
691+ { ALT : ( ) => this . CONSUME ( lexer . Identifier , { LABEL : 'value' } ) } ,
692+ ] ) ;
693+ this . CONSUME ( lexer . RSquareBracket ) ;
694+ } ) ;
695+
679696 private arrayExpression = this . RULE ( 'arrayExpression' , ( ) => {
680697 this . CONSUME ( lexer . LParen ) ;
681698 this . AT_LEAST_ONE_SEP ( {
0 commit comments