diff options
author | Paul "LeoNerd" Evans <leonerd@leonerd.org.uk> | 2021-01-22 17:57:08 +0000 |
---|---|---|
committer | Paul "LeoNerd" Evans <leonerd@leonerd.org.uk> | 2021-02-04 14:20:53 +0000 |
commit | a1325b902d57aa7a99bed3d2ec0fa5ce42836207 (patch) | |
tree | 37ce967cbad3faa9d65d10d33aab6919ec353616 /keywords.c | |
parent | 99dbf64538ee1c097b9f7e93df5a45dbf1fa3e22 (diff) | |
download | perl-a1325b902d57aa7a99bed3d2ec0fa5ce42836207.tar.gz |
Initial attempt at feature 'try'
* Add feature, experimental warning, keyword
* Basic parsing
* Basic implementation as optree fragment
See also
https://github.com/Perl/perl5/issues/18504
Diffstat (limited to 'keywords.c')
-rw-r--r-- | keywords.c | 42 |
1 files changed, 33 insertions, 9 deletions
diff --git a/keywords.c b/keywords.c index b2dd655fdd..624debc80a 100644 --- a/keywords.c +++ b/keywords.c @@ -203,7 +203,7 @@ Perl_keyword (pTHX_ const char *name, I32 len, bool all_keywords) goto unknown; } - case 3: /* 29 tokens of length 3 */ + case 3: /* 30 tokens of length 3 */ switch (name[0]) { case 'E': @@ -463,13 +463,27 @@ Perl_keyword (pTHX_ const char *name, I32 len, bool all_keywords) } case 't': - if (name[1] == 'i' && - name[2] == 'e') - { /* tie */ - return -KEY_tie; - } + switch (name[1]) + { + case 'i': + if (name[2] == 'e') + { /* tie */ + return -KEY_tie; + } - goto unknown; + goto unknown; + + case 'r': + if (name[2] == 'y') + { /* try */ + return (all_keywords || FEATURE_TRY_IS_ENABLED ? KEY_try : 0); + } + + goto unknown; + + default: + goto unknown; + } case 'u': if (name[1] == 's' && @@ -964,7 +978,7 @@ Perl_keyword (pTHX_ const char *name, I32 len, bool all_keywords) goto unknown; } - case 5: /* 39 tokens of length 5 */ + case 5: /* 40 tokens of length 5 */ switch (name[0]) { case 'B': @@ -1046,6 +1060,16 @@ Perl_keyword (pTHX_ const char *name, I32 len, bool all_keywords) case 'c': switch (name[1]) { + case 'a': + if (name[2] == 't' && + name[3] == 'c' && + name[4] == 'h') + { /* catch */ + return (all_keywords || FEATURE_TRY_IS_ENABLED ? KEY_catch : 0); + } + + goto unknown; + case 'h': switch (name[2]) { @@ -3451,5 +3475,5 @@ unknown: } /* Generated from: - * dd384f0c948716414a93d758d89a38e3c8116acfdc48eb7e34fa6737887097d5 regen/keywords.pl + * 3a4f2004642b00b871c01cbdc018f6ca5ead6b4e0b2b184120c60b0b62a229dd regen/keywords.pl * ex: set ro: */ |