1B::Hooks::Parser(3)   User Contributed Perl Documentation  B::Hooks::Parser(3)
2
3
4

NAME

6       B::Hooks::Parser - Interface to perl's parser variables
7

VERSION

9       version 0.21
10

DESCRIPTION

12       This module provides an API for parts of the perl parser. It can be
13       used to modify code while it's being parsed.
14

Perl API

16   "setup()"
17       Does some initialization work. This must be called before any other
18       functions of this module if you intend to use "set_linestr". Returns an
19       id that can be used to disable the magic using "teardown".
20
21   "teardown($id)"
22       Disables magic registered using "setup".
23
24   "get_linestr()"
25       Returns the line the parser is currently working on, or undef if perl
26       isn't parsing anything right now.
27
28   "get_linestr_offset()"
29       Returns the position within the current line to which perl has already
30       parsed the input, or -1 if nothing is being parsed currently.
31
32   "set_linestr($string)"
33       Sets the line the perl parser is currently working on to $string.
34
35       Note that perl won't notice any changes in the line string after the
36       position returned by "get_linestr_offset".
37
38       Throws an exception when nothing is being compiled.
39
40   "inject($string)"
41       Convenience function to insert a piece of perl code into the current
42       line string (as returned by "get_linestr") at the current offset (as
43       returned by "get_linestr_offset").
44
45   "get_lex_stuff()"
46       Returns the string of additional stuff resulting from recent lexing
47       that is being held onto by the lexer.  For example, the content of a
48       quoted string goes here.  Returns "undef" if there is no such stuff.
49
50   "clear_lex_stuff()"
51       Discard the string of additional stuff resulting from recent lexing
52       that is being held onto by the lexer.
53

C API

55       The following functions work just like their equivalent in the Perl
56       API, except that they can't handle embedded "NUL" bytes in strings.
57
58   "hook_op_check_id hook_parser_setup (void)"
59       Note: may be implemented as a macro.
60
61   "void hook_parser_teardown (hook_op_check_id id)"
62   "const char *hook_parser_get_linestr (pTHX)"
63   "IV hook_parser_get_linestr_offset (pTHX)"
64   "void hook_parser_set_linestr (pTHX_ const char *new_value)"
65   "char *hook_parser_get_lex_stuff (pTHX)"
66   "void hook_parser_clear_lex_stuff (pTHX)"

SUPPORT

68       Bugs may be submitted through the RT bug tracker
69       <https://rt.cpan.org/Public/Dist/Display.html?Name=B-Hooks-Parser> (or
70       bug-B-Hooks-Parser@rt.cpan.org <mailto:bug-B-Hooks-
71       Parser@rt.cpan.org>).
72

AUTHOR

74       Florian Ragwitz <rafl@debian.org>
75

CONTRIBUTORS

77       •   Karen Etheridge <ether@cpan.org>
78
79       •   Zefram <zefram@fysh.org>
80
81       •   Vincent Pit <perl@profvince.com>
82
83       •   Alexandr Ciornii <alexchorny@gmail.com>
84
85       •   Karl Williamson <khw@cpan.org>
86
87       •   Liu Kang-min <gugod@gugod.org>
88
90       This software is copyright (c) 2008 by Florian Ragwitz.
91
92       This is free software; you can redistribute it and/or modify it under
93       the same terms as the Perl 5 programming language system itself.
94
95
96
97perl v5.36.0                      2022-07-22               B::Hooks::Parser(3)
Impressum