.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "HTML::Mason::Lexer 3pm" .TH HTML::Mason::Lexer 3pm "2017-11-06" "perl v5.26.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" HTML::Mason::Lexer \- Generates events based on component source lexing .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& my $lexer = HTML::Mason::Lexer\->new; \& \& $lexer\->lex( comp_source => $source, name => $comp_name, compiler => $compiler ); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The Lexer works in tandem with the Compiler to turn Mason component source into something else, generally Perl code. .PP As the lexer finds component elements, like a tag or block, it calls the appropriate event methods in the compiler object it was given. .PP It has only a few public methods. .PP You can replace this lexer with one of your own simply by telling the Compiler to use a different lexer class. Your lexer class simply needs to call the appropriate methods in the Component Class's \s-1API\s0 as it scans the source. .SH "METHODS" .IX Header "METHODS" The lexer has very few public methods. .IP "new" 4 .IX Item "new" This method creates a new Lexer object. This methods takes no parameters. .IP "lex ( comp_source => ..., name => ..., compiler => ... )" 4 .IX Item "lex ( comp_source => ..., name => ..., compiler => ... )" This method tells the lexer to start scanning the given component source. All of these parameters are required. The \f(CW\*(C`name\*(C'\fR parameter will be used in any error messages generated during lexing. The \&\f(CW\*(C`compiler\*(C'\fR object must be an object that implements the Mason Component \s-1API.\s0 .IP "line_number" 4 .IX Item "line_number" The current line number that the lexer has reached. .IP "name" 4 .IX Item "name" The name of the component currently being lexed. .IP "throw_syntax_error ($error)" 4 .IX Item "throw_syntax_error ($error)" This throws an \f(CW\*(C`HTML::Mason::Exception::Syntax\*(C'\fR error with the given error message as well as additional information about the component source. .Sp This method is used by both the Lexer and the Compiler. .SH "SUBCLASSING" .IX Header "SUBCLASSING" Any subclass of the lexer should declare itself to be a subclass of \&\f(CW\*(C`HTML::Mason::Lexer\*(C'\fR, even if it plans to override all of its public methods. .PP If you want your subclass to work with the existing Compiler classes in Mason, you must implement the methods listed above. If you plan to use a custom Compiler class that you're writing, you can do whatever you want. .PP We recommend that any parameters you add to Lexer be read-only, because the compiler object_id is only computed once on creation and would not reflect any changes to Lexer parameters.