Jean-Damien Durand > MarpaX-Languages-ECMAScript-AST-0.005 > script/generateTemplate.pl

Download:
MarpaX-Languages-ECMAScript-AST-0.005.tar.gz

Annotate this POD

Website

CPAN RT

Open  0
View/Report Bugs
Source   Latest Release: MarpaX-Languages-ECMAScript-AST-0.018

G1_$ruleId(\$self, \$value, \$index)

Transpilation of G1 rule No $ruleId, i.e. $lhs ::= @rhs

\$value is the value of RHS No \$index (starting at 0).

DESCRIPTION ^

Generated generic template.

SUBROUTINES/METHODS ^

new($class, %options)

Instantiate a new object. Takes as optional argument a hash that may contain the following key/values:

g1Callback

G1 callback (CODE ref).

g1CallbackArgs

G1 callback arguments (ARRAY ref). The g1 callback is called like: &$g1Callback(@{$g1CallbackArgs}, \$rc, $ruleId, $value, $index, $lhs, @rhs), where $value is the AST parse tree value of RHS No $index of this G1 rule number $ruleId, whose full definition is $lhs ::= @rhs. If the callback is defined, this will always be executed first, and it must return a true value putting its eventual result in $rc. Only when it returns true, lexemes are processed.

lexemeCallback

lexeme callback (CODE ref).

lexemeCallbackArgs

Lexeme callback arguments (ARRAY ref). The lexeme callback is called like: &$lexemeCallback(@{$lexemeCallbackArgs}, \$rc, $name, $ruleId, $value, $index, $lhs, @rhs), where $value is the AST parse tree value of RHS No $index of this G1 rule number $ruleId, whose full definition is $lhs ::= @rhs. The RHS being a lexeme, $name contains the lexeme's name. If the callback is defined, this will always be executed first, and it must return a true value putting its result in $rc, otherwise default behaviour applies: return the lexeme value as-is.

lexeme($self, $value)

Returns the characters of lexeme inside $value, that is an array reference. C.f. grammar default lexeme action.

indent($self, $inc)

Returns indentation, i.e. two spaces times current number of indentations. Optional $inc is used to change the number of indentations.

transpile($self, $ast)

Tranpiles the $ast AST, that is the parse tree value from Marpa.

syntax highlighting: