From ccb59398e3774331b5bc0839237d7d5e8420a651 Mon Sep 17 00:00:00 2001 From: Per Hedbor <ph@opera.com> Date: Sat, 3 Nov 2012 17:59:13 +0100 Subject: [PATCH] Implemented the safe index operator formerly known as ?[]. It has now been renamed to [?] since that does not conflict with any other syntax in pike. As an example: int foo( array(int) a ) { return a[?10]; } --- src/lexer.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/lexer.h b/src/lexer.h index 86f68bc0a2..7d983a6f6f 100644 --- a/src/lexer.h +++ b/src/lexer.h @@ -1088,9 +1088,6 @@ unknown_directive: They however conflict with valid ?: syntaxes. */ - /* if( GOBBLE('[' ) ) */ - /* return TOK_SAFE_START_INDEX; */ - /* if( GOBBLE('.' ) ) */ /* return TOK_SAFE_INDEX; */ @@ -1099,12 +1096,16 @@ unknown_directive: case '~': case '@': case ')': - case '[': case '{': case ';': case '}': return c; + case '[': + if( GOBBLE('?' ) ) + return TOK_SAFE_START_INDEX; + return c; + case '`': { char *tmp; -- GitLab