1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
|
<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>HTML::Mason::Lexer - Generates events based on component source lexing</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:root@localhost" />
</head>
<body style="background-color: white">
<p><A NAME="__index__"></a></p>
<!-- INDEX BEGIN -->
<ul>
<li><A HREF="#name">NAME</a></li>
<li><A HREF="#synopsis">SYNOPSIS</a></li>
<li><A HREF="#description">DESCRIPTION</a></li>
<li><A HREF="#methods">METHODS</a></li>
<li><A HREF="#subclassing">SUBCLASSING</a></li>
</ul>
<!-- INDEX END -->
<hr />
<p>
</p>
<h1><A NAME="name">NAME</a></h1>
<p>HTML::Mason::Lexer - Generates events based on component source lexing</p>
<p>
</p>
<hr />
<h1><A NAME="synopsis">SYNOPSIS</a></h1>
<pre>
my $lexer = HTML::Mason::Lexer->new;</pre>
<pre>
$lexer->lex( comp_source => $source, name => $comp_name, compiler => $compiler );</pre>
<p>
</p>
<hr />
<h1><A NAME="description">DESCRIPTION</a></h1>
<p>The Lexer works in tandem with the Compiler to turn Mason component
source into something else, generally Perl code.</p>
<p>As the lexer finds component elements, like a tag or block, it calls
the appropriate event methods in the compiler object it was given.</p>
<p>It has only a few public methods.</p>
<p>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 API as
it scans the source.</p>
<p>
</p>
<hr />
<h1><A NAME="methods">METHODS</a></h1>
<p>The lexer has very few public methods.</p>
<dl>
<dt><strong><A NAME="item_new">new</a></strong>
<dd>
<p>This method creates a new Lexer object. This methods takes no
parameters.</p>
</dd>
</li>
<dt><strong><A NAME="item_lex">lex ( comp_source => ..., name => ..., compiler => ... )</a></strong>
<dd>
<p>This method tells the lexer to start scanning the given component
source. All of these parameters are required. The <A HREF="#item_name"><code>name</code></a> parameter
will be used in any error messages generated during lexing. The
<code>compiler</code> object must be an object that implements the Mason
Component API.</p>
</dd>
</li>
<dt><strong><A NAME="item_line_number">line_number</a></strong>
<dd>
<p>The current line number that the lexer has reached.</p>
</dd>
</li>
<dt><strong><A NAME="item_name">name</a></strong>
<dd>
<p>The name of the component currently being lexed.</p>
</dd>
</li>
<dt><strong><A NAME="item_throw_syntax_error">throw_syntax_error ($error)</a></strong>
<dd>
<p>This throws an <code>HTML::Mason::Exception::Syntax</code> error with the given
error message as well as additional information about the component
source.</p>
</dd>
<dd>
<p>This method is used by both the Lexer and the Compiler.</p>
</dd>
</li>
</dl>
<p>
</p>
<hr />
<h1><A NAME="subclassing">SUBCLASSING</a></h1>
<p>Any subclass of the lexer should declare itself to be a subclass of
<code>HTML::Mason::Lexer</code>, even if it plans to override all of its public
methods.</p>
<p>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.</p>
<p>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.</p>
</body>
</html>
|