diff --git a/src/language.yacc b/src/language.yacc index 9d60bf5296705a3239d021f4e7b3cd900fcaf334..13cc967174fe1a9be0b2a8c5ef0ed601c584fdca 100644 --- a/src/language.yacc +++ b/src/language.yacc @@ -3755,7 +3755,7 @@ expr4: string } | expr4 TOK_SAFE_INDEX line_number_info TOK_IDENTIFIER { - /* A?->B to ((tmp=A) && tmp->B) */ + /* A->?B to ((tmp=A) && tmp->B) */ int temporary; if( $1 && ($1->token == F_LOCAL) ) { diff --git a/src/lexer.h b/src/lexer.h index 833dbf50d6efaca864ee745133e942b0e14d814b..7bb5f8bb0f3e6fcf4742147aaa0d7ef34ad4262b 100644 --- a/src/lexer.h +++ b/src/lexer.h @@ -1062,7 +1062,11 @@ unknown_directive: case '-': if(GOBBLE('=')) return TOK_SUB_EQ; - if(GOBBLE('>')) return TOK_ARROW; + if(GOBBLE('>')) + if(GOBBLE('?') ) /* ->? */ + return TOK_SAFE_INDEX; + else + return TOK_ARROW; if(GOBBLE('-')) return TOK_DEC; return '-'; @@ -1132,24 +1136,13 @@ unknown_directive: if(GOBBLE(':')) return TOK_LOR; - if(GOBBLE('-') ) /* safe index: ?-> or ?[] */ + if(GOBBLE('-') ) /* old safe index: ?->, depreceated in 8.1+ */ { if( GOBBLE( '>' ) ) /* ?-> */ return TOK_SAFE_INDEX; SKIPN(-1); /* Undo GOBBLE('-') above */ } - /* Probably wanted: - - ?. for safe constant index - ?[] for safe [] index - - They however conflict with valid ?: syntaxes. - */ - - /* if( GOBBLE('.' ) ) */ - /* return TOK_SAFE_INDEX; */ - case ']': case ',': case '~':