/usr/local/perl/lib/site_perl/5.6.1/sun4-solaris/HTML/Embperl/Syntax.pm |
Embperl base class for defining custom syntaxes
HTML::Embperl::Syntax provides a base class from which all custom syntaxes should be derived. Currently Embperl comes with the following derived syntaxes:
EmbperlHtml
and EmbperlBlocks
You can choose which syntax is used inside your page, either by
the EMBPERL_SYNTAX
configuration directive, the syntax
,
parameter to Execute
or the [$ syntax $]
metacommand.
You can also specify multiple syntaxes e.g.
PerlSetEnv EMBPERL_SYNTAX "Embperl SSI"
Execute ({inputfile => '*', syntax => 'Embperl ASP'}) ;
The syntax metacommand allows to switch the syntax or to add or subtract syntaxes e.g.
[$ syntax + Mail $]
will add the Mail taglib so the <mail:send> tag is available after this line.
[$ syntax - Mail $]
now the <mail:send> tag is unknown again
[$ syntax SSI $]
now you can only use SSI commands inside your page.
If you want to define your own syntax, you have to derive a new class from one of the existing ones and extent it with new tags/functionality. The best thing is to take a look at the syntax classes that comes with Embperl. (inside the directory Embperl/Syntax/).
For example if you want to add new html tags, derive from HTML::Embperl::Syntax::HTML, if you want to add new metacommands derive from HTML::Embperl::Syntax::EmbperlBlocks.
Some of the classes define addtionaly methods to easily add new tags. See the respective pod file, which methods are available for a certain class.
HTML::Embperl::Syntax defines the basic methods to create a syntax:
Create a new syntax class. This method should only be called inside a constructor of a derived class.
This adds a new element to the root of the parser tree. $elements
must be a
hashref. See HTML::Embperl::Syntax::ASP for an example.
This gives you the possibility to add some Perl code, that is always executed
at the beginning of a document ($initcode
), at the end of the document
($termcode
) or at compile time ($compiletimecode
). The three strings must
be valid Perl code. See HTML::Embperl::Syntax::SSI for an example. $procinfo
is a hashref that can consits of addtional processor infos (see below) for the
document.
Returns the root of the parser tree.
Returns a syntax object which is build form the syntaxes named
in $name
. If $oldname
is given, $name
can start with a +
or -
to add or subtract a syntax. This is normaly only needed by Embperl itself
or to implement a syntax switch statement (see HTML::Embperl::Syntax::SSI
for an example.)
Clones a hash which is given as hashref in $old
, optional replace the tags
given in the hashref $replace
and return a hashref to the new hash.
Internaly the syntax object builds a data structure which serve as base for the parser. This structure consists of a list of tokens and options, which starts with a dash:
ntypText
all special
characters are escaped.
Each token can have the following members:
start
and end
or contains
could be specified.
NOTE: If a item that only specfifies contains but no text should be compiled, you must specfify a nodname.
optRawInput
isn't set unescape the data of the inside the node
The processor info gives information how to compile this token to valid code that can be executed later on by the processor. There could be informations for multiple processors. At the moment only the embperl processor is defined. Normaly you must not worry about different processor, because the syntax object knows inside that all procinfo is for the embperl processor. procinfo is a parameter to many methods, it is a hashref and can take the following items:
All of the above special values (expect those start with $) allows the following modifiers:
writing a minus sign (-) after * ! = or ~ will cause the child/attribute not to be included, but the condition is evaluated. Writing an ' will cause the value to be quoted.
perlcode
.
$_[0]
contains the Embperl request object. The method Code
can be used to
get or set the perl code that should be generated by this node.
If the code begins with #!- all newlines are removed in the code. This is basicly usefull to keep all code on the same line, so the linenumber in error reporting matches the line in the source.
perlcode
.
$_[0]
contains the Embperl request object. The method Code
can be used to
get or set the perl code that should be generated by this node.
If the code begins with #!- all newlines are removed in the code. This is basicly usefull to keep all code on the same line, so the linenumber in error reporting matches the line in the source.
push
, stackmatch
=item stackname2 => <name>
Name of stack for push2
=item push => <value>
Push value on stack which name is given with stackname
. Value could
include the same specical values as perlcode
stackname2
. Value could
include the same specical values as perlcode
stackname
is the
same as the given value. If not give a error message about tag mismatch. Value could
include the same specical values as perlcode
2 means put the following code put into code which is executed direct after compilation. This is mainly for defining subs, or using modules etc.
/usr/local/perl/lib/site_perl/5.6.1/sun4-solaris/HTML/Embperl/Syntax.pm |