| 1 |
|
| /* You may distribute under the terms of either the GNU General Public License |
| 2 |
|
| * or the Artistic License (the same terms as Perl itself) |
| 3 |
|
| * |
| 4 |
|
| * (C) Paul Evans, 2021 -- leonerd@leonerd.org.uk |
| 5 |
|
| */ |
| 6 |
|
| |
| 7 |
|
| #include "EXTERN.h" |
| 8 |
|
| #include "perl.h" |
| 9 |
|
| #include "XSUB.h" |
| 10 |
|
| |
| 11 |
|
| #include "XSParseKeyword.h" |
| 12 |
|
| |
| 13 |
|
| static const char hintkey[] = "t::flags/permit"; |
| 14 |
|
| |
| 15 |
2 |
| static int build_ident(pTHX_ OP **out, XSParseKeywordPiece *arg0, void *hookdata) |
| 16 |
|
| { |
| 17 |
2 |
| *out = newSVOP(OP_CONST, 0, arg0->sv); |
| 18 |
2 |
| return KEYWORD_PLUGIN_STMT; |
| 19 |
|
| } |
| 20 |
|
| |
| 21 |
|
| static const struct XSParseKeywordHooks hooks_autosemi = { |
| 22 |
|
| .flags = XPK_FLAG_STMT|XPK_FLAG_AUTOSEMI, |
| 23 |
|
| .permit_hintkey = hintkey, |
| 24 |
|
| |
| 25 |
|
| .piece1 = XPK_IDENT, |
| 26 |
|
| .build1 = &build_ident, |
| 27 |
|
| }; |
| 28 |
|
| |
| 29 |
2 |
| static int build_lex_ident(pTHX_ OP **out, XSParseKeywordPiece *arg0, void *hookdata) |
| 30 |
|
| { |
| 31 |
2 |
| SV *sv = newSVpvs(""); |
| 32 |
2 |
▶ | if(PL_parser->in_my) |
Branch: 1 branch
| Branch | True | False | Total |
| if(PL_parser->in_my) |
1 |
1 |
2 |
|
| 33 |
1 |
| sv_catpvs(sv, "my "); |
| 34 |
2 |
| sv_catsv(sv, arg0->sv); |
| 35 |
2 |
| *out = newSVOP(OP_CONST, 0, sv); |
| 36 |
2 |
| return KEYWORD_PLUGIN_EXPR; |
| 37 |
|
| } |
| 38 |
|
| |
| 39 |
|
| static const struct XSParseKeywordHooks hooks_lex = { |
| 40 |
|
| .flags = XPK_FLAG_EXPR|XPK_FLAG_PERMIT_LEXICAL, |
| 41 |
|
| .permit_hintkey = hintkey, |
| 42 |
|
| |
| 43 |
|
| .piece1 = XPK_IDENT, |
| 44 |
|
| .build1 = &build_lex_ident, |
| 45 |
|
| }; |
| 46 |
|
| |
| 47 |
|
| MODULE = t::flags PACKAGE = t::flags |
| 48 |
|
| |
| 49 |
|
| BOOT: |
| 50 |
2 |
| boot_xs_parse_keyword(0); |
| 51 |
|
| |
| 52 |
2 |
| register_xs_parse_keyword("flagautosemi", &hooks_autosemi, NULL); |
| 53 |
|
| |
| 54 |
2 |
| register_xs_parse_keyword("flaglex", &hooks_lex, NULL); |