1HTML::Mason::Lexer(3) User Contributed Perl DocumentationHTML::Mason::Lexer(3)
2
3
4

NAME

6       HTML::Mason::Lexer - Generates events based on component source lexing
7

SYNOPSIS

9         my $lexer = HTML::Mason::Lexer->new;
10
11         $lexer->lex( comp_source => $source, name => $comp_name, compiler => $compiler );
12

DESCRIPTION

14       The Lexer works in tandem with the Compiler to turn Mason component
15       source into something else, generally Perl code.
16
17       As the lexer finds component elements, like a tag or block, it calls
18       the appropriate event methods in the compiler object it was given.
19
20       It has only a few public methods.
21
22       You can replace this lexer with one of your own simply by telling the
23       Compiler to use a different lexer class.  Your lexer class simply needs
24       to call the appropriate methods in the Component Class's API as it
25       scans the source.
26

METHODS

28       The lexer has very few public methods.
29
30       new This method creates a new Lexer object.  This methods takes no
31           parameters.
32
33       lex ( comp_source => ..., name => ..., compiler => ... )
34           This method tells the lexer to start scanning the given component
35           source.  All of these parameters are required.  The "name"
36           parameter will be used in any error messages generated during
37           lexing.  The "compiler" object must be an object that implements
38           the Mason Component API.
39
40       line_number
41           The current line number that the lexer has reached.
42
43       name
44           The name of the component currently being lexed.
45
46       throw_syntax_error ($error)
47           This throws an "HTML::Mason::Exception::Syntax" error with the
48           given error message as well as additional information about the
49           component source.
50
51           This method is used by both the Lexer and the Compiler.
52

SUBCLASSING

54       Any subclass of the lexer should declare itself to be a subclass of
55       "HTML::Mason::Lexer", even if it plans to override all of its public
56       methods.
57
58       If you want your subclass to work with the existing Compiler classes in
59       Mason, you must implement the methods listed above.  If you plan to use
60       a custom Compiler class that you're writing, you can do whatever you
61       want.
62
63       We recommend that any parameters you add to Lexer be read-only, because
64       the compiler object_id is only computed once on creation and would not
65       reflect any changes to Lexer parameters.
66
67
68
69perl v5.32.1                      2021-01-27             HTML::Mason::Lexer(3)
Impressum