@ 261102.1

261006.1 · a19efdd45dfe91329a7d266efb2ac0a64279a938

Parse `?//` as `?` and `//` outside destructuring patterns (#3593)

The lexer returned a single ALTERNATION token for `?//`, so any `?` followed by `//` was consumed by it, and `.name?//"unknown"` failed to parse even though they read as the optional operator followed by the alternative operator.

Drop the lexer rule and spell the destructuring alternative operator as `'?' "//"` instead. So `x ?// y` now parses as `x? // y`, while `. as [$a] ?// [$b] | ...` keeps its meaning. Note that `?` and `//` may now be separated by whitespaces inside a pattern.

reading declarations

Changes to src/parser.h. All files

src/parser.h

@@ -111,14 +111,13 @@ struct lexer_param;     SETDEFINEDOR = 293,            /* "//="  */     LESSEQ = 294,                  /* "<="  */     GREATEREQ = 295,               /* ">="  */-    ALTERNATION = 296,             /* "?//"  */-    QQSTRING_START = 297,          /* QQSTRING_START  */-    QQSTRING_TEXT = 298,           /* QQSTRING_TEXT  */-    QQSTRING_INTERP_START = 299,   /* QQSTRING_INTERP_START  */-    QQSTRING_INTERP_END = 300,     /* QQSTRING_INTERP_END  */-    QQSTRING_END = 301,            /* QQSTRING_END  */-    FUNCDEF = 302,                 /* FUNCDEF  */-    NONOPT = 303                   /* NONOPT  */+    QQSTRING_START = 296,          /* QQSTRING_START  */+    QQSTRING_TEXT = 297,           /* QQSTRING_TEXT  */+    QQSTRING_INTERP_START = 298,   /* QQSTRING_INTERP_START  */+    QQSTRING_INTERP_END = 299,     /* QQSTRING_INTERP_END  */+    QQSTRING_END = 300,            /* QQSTRING_END  */+    FUNCDEF = 301,                 /* FUNCDEF  */+    NONOPT = 302                   /* NONOPT  */   };   typedef enum yytokentype yytoken_kind_t; #endif@@ -165,14 +164,13 @@ struct lexer_param; #define SETDEFINEDOR 293 #define LESSEQ 294 #define GREATEREQ 295-#define ALTERNATION 296-#define QQSTRING_START 297-#define QQSTRING_TEXT 298-#define QQSTRING_INTERP_START 299-#define QQSTRING_INTERP_END 300-#define QQSTRING_END 301-#define FUNCDEF 302-#define NONOPT 303+#define QQSTRING_START 296+#define QQSTRING_TEXT 297+#define QQSTRING_INTERP_START 298+#define QQSTRING_INTERP_END 299+#define QQSTRING_END 300+#define FUNCDEF 301+#define NONOPT 302  /* Value type.  */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED@@ -183,7 +181,7 @@ union YYSTYPE   jv literal;   block blk; -#line 187 "src/parser.h"+#line 185 "src/parser.h"  }; typedef union YYSTYPE YYSTYPE;