/view/SSTemplateParser.php
PHP | 4793 lines | 4258 code | 256 blank | 279 comment | 755 complexity | 8fc7ab4185d38da482a6c4e135d64fa7 MD5 | raw file
Possible License(s): BSD-3-Clause, MIT, CC-BY-3.0, GPL-2.0, AGPL-1.0, LGPL-2.1
Large files files are truncated, but you can click here to view the full file
- <?php
- /*
- WARNING: This file has been machine generated. Do not edit it, or your changes will be overwritten next time it is compiled.
- */
- // We want this to work when run by hand too
- if (defined(THIRDPARTY_PATH)) {
- require_once(THIRDPARTY_PATH . '/php-peg/Parser.php');
- }
- else {
- $base = dirname(__FILE__);
- require_once($base.'/../thirdparty/php-peg/Parser.php');
- }
- /**
- * This is the exception raised when failing to parse a template. Note that we don't currently do any static analysis,
- * so we can't know if the template will run, just if it's malformed. It also won't catch mistakes that still look
- * valid.
- *
- * @package framework
- * @subpackage view
- */
- class SSTemplateParseException extends Exception {
- function __construct($message, $parser) {
- $prior = substr($parser->string, 0, $parser->pos);
- preg_match_all('/\r\n|\r|\n/', $prior, $matches);
- $line = count($matches[0])+1;
- parent::__construct("Parse error in template on line $line. Error was: $message");
- }
- }
- /**
- * This is the parser for the SilverStripe template language. It gets called on a string and uses a php-peg parser
- * to match that string against the language structure, building up the PHP code to execute that structure as it
- * parses
- *
- * The $result array that is built up as part of the parsing (see thirdparty/php-peg/README.md for more on how
- * parsers build results) has one special member, 'php', which contains the php equivalent of that part of the
- * template tree.
- *
- * Some match rules generate alternate php, or other variations, so check the per-match documentation too.
- *
- * Terms used:
- *
- * Marked: A string or lookup in the template that has been explictly marked as such - lookups by prepending with
- * "$" (like $Foo.Bar), strings by wrapping with single or double quotes ('Foo' or "Foo")
- *
- * Bare: The opposite of marked. An argument that has to has it's type inferred by usage and 2.4 defaults.
- *
- * Example of using a bare argument for a loop block: <% loop Foo %>
- *
- * Block: One of two SS template structures. The special characters "<%" and "%>" are used to wrap the opening and
- * (required or forbidden depending on which block exactly) closing block marks.
- *
- * Open Block: An SS template block that doesn't wrap any content or have a closing end tag (in fact, a closing end
- * tag is forbidden)
- *
- * Closed Block: An SS template block that wraps content, and requires a counterpart <% end_blockname %> tag
- *
- * Angle Bracket: angle brackets "<" and ">" are used to eat whitespace between template elements
- * N: eats white space including newlines (using in legacy _t support)
- *
- * @package framework
- * @subpackage view
- */
- class SSTemplateParser extends Parser implements TemplateParser {
- /**
- * @var bool - Set true by SSTemplateParser::compileString if the template should include comments intended
- * for debugging (template source, included files, etc)
- */
- protected $includeDebuggingComments = false;
- /**
- * Stores the user-supplied closed block extension rules in the form:
- * array(
- * 'name' => function (&$res) {}
- * )
- * See SSTemplateParser::ClosedBlock_Handle_Loop for an example of what the callable should look like
- * @var array
- */
- protected $closedBlocks = array();
- /**
- * Stores the user-supplied open block extension rules in the form:
- * array(
- * 'name' => function (&$res) {}
- * )
- * See SSTemplateParser::OpenBlock_Handle_Base_tag for an example of what the callable should look like
- * @var array
- */
- protected $openBlocks = array();
- /**
- * Allow the injection of new closed & open block callables
- * @param array $closedBlocks
- * @param array $openBlocks
- */
- public function __construct($closedBlocks = array(), $openBlocks = array()) {
- $this->setClosedBlocks($closedBlocks);
- $this->setOpenBlocks($openBlocks);
- }
- /**
- * Override the function that constructs the result arrays to also prepare a 'php' item in the array
- */
- function construct($matchrule, $name, $arguments = null) {
- $res = parent::construct($matchrule, $name, $arguments);
- if (!isset($res['php'])) $res['php'] = '';
- return $res;
- }
- /**
- * Set the closed blocks that the template parser should use
- *
- * This method will delete any existing closed blocks, please use addClosedBlock if you don't
- * want to overwrite
- * @param array $closedBlocks
- * @throws InvalidArgumentException
- */
- public function setClosedBlocks($closedBlocks) {
- $this->closedBlocks = array();
- foreach ((array) $closedBlocks as $name => $callable) {
- $this->addClosedBlock($name, $callable);
- }
- }
- /**
- * Set the open blocks that the template parser should use
- *
- * This method will delete any existing open blocks, please use addOpenBlock if you don't
- * want to overwrite
- * @param array $openBlocks
- * @throws InvalidArgumentException
- */
- public function setOpenBlocks($openBlocks) {
- $this->openBlocks = array();
- foreach ((array) $openBlocks as $name => $callable) {
- $this->addOpenBlock($name, $callable);
- }
- }
- /**
- * Add a closed block callable to allow <% name %><% end_name %> syntax
- * @param string $name The name of the token to be used in the syntax <% name %><% end_name %>
- * @param callable $callable The function that modifies the generation of template code
- * @throws InvalidArgumentException
- */
- public function addClosedBlock($name, $callable) {
- $this->validateExtensionBlock($name, $callable, 'Closed block');
- $this->closedBlocks[$name] = $callable;
- }
- /**
- * Add a closed block callable to allow <% name %> syntax
- * @param string $name The name of the token to be used in the syntax <% name %>
- * @param callable $callable The function that modifies the generation of template code
- * @throws InvalidArgumentException
- */
- public function addOpenBlock($name, $callable) {
- $this->validateExtensionBlock($name, $callable, 'Open block');
- $this->openBlocks[$name] = $callable;
- }
- /**
- * Ensures that the arguments to addOpenBlock and addClosedBlock are valid
- * @param $name
- * @param $callable
- * @param $type
- * @throws InvalidArgumentException
- */
- protected function validateExtensionBlock($name, $callable, $type) {
- if (!is_string($name)) {
- throw new InvalidArgumentException(
- sprintf(
- "Name argument for %s must be a string",
- $type
- )
- );
- } elseif (!is_callable($callable)) {
- throw new InvalidArgumentException(
- sprintf(
- "Callable %s argument named '%s' is not callable",
- $type,
- $name
- )
- );
- }
- }
- /* Template: (Comment | Translate | If | Require | CacheBlock | UncachedBlock | OldI18NTag | Include | ClosedBlock |
- OpenBlock | MalformedBlock | Injection | Text)+ */
- protected $match_Template_typestack = array('Template');
- function match_Template ($stack = array()) {
- $matchrule = "Template"; $result = $this->construct($matchrule, $matchrule, null);
- $count = 0;
- while (true) {
- $res_50 = $result;
- $pos_50 = $this->pos;
- $_49 = NULL;
- do {
- $_47 = NULL;
- do {
- $res_0 = $result;
- $pos_0 = $this->pos;
- $matcher = 'match_'.'Comment'; $key = $matcher; $pos = $this->pos;
- $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
- if ($subres !== FALSE) {
- $this->store( $result, $subres );
- $_47 = TRUE; break;
- }
- $result = $res_0;
- $this->pos = $pos_0;
- $_45 = NULL;
- do {
- $res_2 = $result;
- $pos_2 = $this->pos;
- $matcher = 'match_'.'Translate'; $key = $matcher; $pos = $this->pos;
- $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
- if ($subres !== FALSE) {
- $this->store( $result, $subres );
- $_45 = TRUE; break;
- }
- $result = $res_2;
- $this->pos = $pos_2;
- $_43 = NULL;
- do {
- $res_4 = $result;
- $pos_4 = $this->pos;
- $matcher = 'match_'.'If'; $key = $matcher; $pos = $this->pos;
- $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
- if ($subres !== FALSE) {
- $this->store( $result, $subres );
- $_43 = TRUE; break;
- }
- $result = $res_4;
- $this->pos = $pos_4;
- $_41 = NULL;
- do {
- $res_6 = $result;
- $pos_6 = $this->pos;
- $matcher = 'match_'.'Require'; $key = $matcher; $pos = $this->pos;
- $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
- if ($subres !== FALSE) {
- $this->store( $result, $subres );
- $_41 = TRUE; break;
- }
- $result = $res_6;
- $this->pos = $pos_6;
- $_39 = NULL;
- do {
- $res_8 = $result;
- $pos_8 = $this->pos;
- $matcher = 'match_'.'CacheBlock'; $key = $matcher; $pos = $this->pos;
- $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
- if ($subres !== FALSE) {
- $this->store( $result, $subres );
- $_39 = TRUE; break;
- }
- $result = $res_8;
- $this->pos = $pos_8;
- $_37 = NULL;
- do {
- $res_10 = $result;
- $pos_10 = $this->pos;
- $matcher = 'match_'.'UncachedBlock'; $key = $matcher; $pos = $this->pos;
- $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
- if ($subres !== FALSE) {
- $this->store( $result, $subres );
- $_37 = TRUE; break;
- }
- $result = $res_10;
- $this->pos = $pos_10;
- $_35 = NULL;
- do {
- $res_12 = $result;
- $pos_12 = $this->pos;
- $matcher = 'match_'.'OldI18NTag'; $key = $matcher; $pos = $this->pos;
- $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
- if ($subres !== FALSE) {
- $this->store( $result, $subres );
- $_35 = TRUE; break;
- }
- $result = $res_12;
- $this->pos = $pos_12;
- $_33 = NULL;
- do {
- $res_14 = $result;
- $pos_14 = $this->pos;
- $matcher = 'match_'.'Include'; $key = $matcher; $pos = $this->pos;
- $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
- if ($subres !== FALSE) {
- $this->store( $result, $subres );
- $_33 = TRUE; break;
- }
- $result = $res_14;
- $this->pos = $pos_14;
- $_31 = NULL;
- do {
- $res_16 = $result;
- $pos_16 = $this->pos;
- $matcher = 'match_'.'ClosedBlock'; $key = $matcher; $pos = $this->pos;
- $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
- if ($subres !== FALSE) {
- $this->store( $result, $subres );
- $_31 = TRUE; break;
- }
- $result = $res_16;
- $this->pos = $pos_16;
- $_29 = NULL;
- do {
- $res_18 = $result;
- $pos_18 = $this->pos;
- $matcher = 'match_'.'OpenBlock'; $key = $matcher; $pos = $this->pos;
- $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
- if ($subres !== FALSE) {
- $this->store( $result, $subres );
- $_29 = TRUE; break;
- }
- $result = $res_18;
- $this->pos = $pos_18;
- $_27 = NULL;
- do {
- $res_20 = $result;
- $pos_20 = $this->pos;
- $matcher = 'match_'.'MalformedBlock'; $key = $matcher; $pos = $this->pos;
- $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
- if ($subres !== FALSE) {
- $this->store( $result, $subres );
- $_27 = TRUE; break;
- }
- $result = $res_20;
- $this->pos = $pos_20;
- $_25 = NULL;
- do {
- $res_22 = $result;
- $pos_22 = $this->pos;
- $matcher = 'match_'.'Injection'; $key = $matcher; $pos = $this->pos;
- $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
- if ($subres !== FALSE) {
- $this->store( $result, $subres );
- $_25 = TRUE; break;
- }
- $result = $res_22;
- $this->pos = $pos_22;
- $matcher = 'match_'.'Text'; $key = $matcher; $pos = $this->pos;
- $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
- if ($subres !== FALSE) {
- $this->store( $result, $subres );
- $_25 = TRUE; break;
- }
- $result = $res_22;
- $this->pos = $pos_22;
- $_25 = FALSE; break;
- }
- while(0);
- if( $_25 === TRUE ) { $_27 = TRUE; break; }
- $result = $res_20;
- $this->pos = $pos_20;
- $_27 = FALSE; break;
- }
- while(0);
- if( $_27 === TRUE ) { $_29 = TRUE; break; }
- $result = $res_18;
- $this->pos = $pos_18;
- $_29 = FALSE; break;
- }
- while(0);
- if( $_29 === TRUE ) { $_31 = TRUE; break; }
- $result = $res_16;
- $this->pos = $pos_16;
- $_31 = FALSE; break;
- }
- while(0);
- if( $_31 === TRUE ) { $_33 = TRUE; break; }
- $result = $res_14;
- $this->pos = $pos_14;
- $_33 = FALSE; break;
- }
- while(0);
- if( $_33 === TRUE ) { $_35 = TRUE; break; }
- $result = $res_12;
- $this->pos = $pos_12;
- $_35 = FALSE; break;
- }
- while(0);
- if( $_35 === TRUE ) { $_37 = TRUE; break; }
- $result = $res_10;
- $this->pos = $pos_10;
- $_37 = FALSE; break;
- }
- while(0);
- if( $_37 === TRUE ) { $_39 = TRUE; break; }
- $result = $res_8;
- $this->pos = $pos_8;
- $_39 = FALSE; break;
- }
- while(0);
- if( $_39 === TRUE ) { $_41 = TRUE; break; }
- $result = $res_6;
- $this->pos = $pos_6;
- $_41 = FALSE; break;
- }
- while(0);
- if( $_41 === TRUE ) { $_43 = TRUE; break; }
- $result = $res_4;
- $this->pos = $pos_4;
- $_43 = FALSE; break;
- }
- while(0);
- if( $_43 === TRUE ) { $_45 = TRUE; break; }
- $result = $res_2;
- $this->pos = $pos_2;
- $_45 = FALSE; break;
- }
- while(0);
- if( $_45 === TRUE ) { $_47 = TRUE; break; }
- $result = $res_0;
- $this->pos = $pos_0;
- $_47 = FALSE; break;
- }
- while(0);
- if( $_47 === FALSE) { $_49 = FALSE; break; }
- $_49 = TRUE; break;
- }
- while(0);
- if( $_49 === FALSE) {
- $result = $res_50;
- $this->pos = $pos_50;
- unset( $res_50 );
- unset( $pos_50 );
- break;
- }
- $count += 1;
- }
- if ($count > 0) { return $this->finalise($result); }
- else { return FALSE; }
- }
- function Template_STR(&$res, $sub) {
- $res['php'] .= $sub['php'] . PHP_EOL ;
- }
- /* Word: / [A-Za-z_] [A-Za-z0-9_]* / */
- protected $match_Word_typestack = array('Word');
- function match_Word ($stack = array()) {
- $matchrule = "Word"; $result = $this->construct($matchrule, $matchrule, null);
- if (( $subres = $this->rx( '/ [A-Za-z_] [A-Za-z0-9_]* /' ) ) !== FALSE) {
- $result["text"] .= $subres;
- return $this->finalise($result);
- }
- else { return FALSE; }
- }
- /* NamespacedWord: / [A-Za-z_\/\\] [A-Za-z0-9_\/\\]* / */
- protected $match_NamespacedWord_typestack = array('NamespacedWord');
- function match_NamespacedWord ($stack = array()) {
- $matchrule = "NamespacedWord"; $result = $this->construct($matchrule, $matchrule, null);
- if (( $subres = $this->rx( '/ [A-Za-z_\/\\\\] [A-Za-z0-9_\/\\\\]* /' ) ) !== FALSE) {
- $result["text"] .= $subres;
- return $this->finalise($result);
- }
- else { return FALSE; }
- }
- /* Number: / [0-9]+ / */
- protected $match_Number_typestack = array('Number');
- function match_Number ($stack = array()) {
- $matchrule = "Number"; $result = $this->construct($matchrule, $matchrule, null);
- if (( $subres = $this->rx( '/ [0-9]+ /' ) ) !== FALSE) {
- $result["text"] .= $subres;
- return $this->finalise($result);
- }
- else { return FALSE; }
- }
- /* Value: / [A-Za-z0-9_]+ / */
- protected $match_Value_typestack = array('Value');
- function match_Value ($stack = array()) {
- $matchrule = "Value"; $result = $this->construct($matchrule, $matchrule, null);
- if (( $subres = $this->rx( '/ [A-Za-z0-9_]+ /' ) ) !== FALSE) {
- $result["text"] .= $subres;
- return $this->finalise($result);
- }
- else { return FALSE; }
- }
- /* CallArguments: :Argument ( < "," < :Argument )* */
- protected $match_CallArguments_typestack = array('CallArguments');
- function match_CallArguments ($stack = array()) {
- $matchrule = "CallArguments"; $result = $this->construct($matchrule, $matchrule, null);
- $_62 = NULL;
- do {
- $matcher = 'match_'.'Argument'; $key = $matcher; $pos = $this->pos;
- $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
- if ($subres !== FALSE) {
- $this->store( $result, $subres, "Argument" );
- }
- else { $_62 = FALSE; break; }
- while (true) {
- $res_61 = $result;
- $pos_61 = $this->pos;
- $_60 = NULL;
- do {
- if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
- if (substr($this->string,$this->pos,1) == ',') {
- $this->pos += 1;
- $result["text"] .= ',';
- }
- else { $_60 = FALSE; break; }
- if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
- $matcher = 'match_'.'Argument'; $key = $matcher; $pos = $this->pos;
- $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
- if ($subres !== FALSE) {
- $this->store( $result, $subres, "Argument" );
- }
- else { $_60 = FALSE; break; }
- $_60 = TRUE; break;
- }
- while(0);
- if( $_60 === FALSE) {
- $result = $res_61;
- $this->pos = $pos_61;
- unset( $res_61 );
- unset( $pos_61 );
- break;
- }
- }
- $_62 = TRUE; break;
- }
- while(0);
- if( $_62 === TRUE ) { return $this->finalise($result); }
- if( $_62 === FALSE) { return FALSE; }
- }
- /**
- * Values are bare words in templates, but strings in PHP. We rely on PHP's type conversion to back-convert
- * strings to numbers when needed.
- */
- function CallArguments_Argument(&$res, $sub) {
- if (!empty($res['php'])) $res['php'] .= ', ';
- $res['php'] .= ($sub['ArgumentMode'] == 'default') ? $sub['string_php'] :
- str_replace('$$FINAL', 'XML_val', $sub['php']);
- }
- /* Call: Method:Word ( "(" < :CallArguments? > ")" )? */
- protected $match_Call_typestack = array('Call');
- function match_Call ($stack = array()) {
- $matchrule = "Call"; $result = $this->construct($matchrule, $matchrule, null);
- $_72 = NULL;
- do {
- $matcher = 'match_'.'Word'; $key = $matcher; $pos = $this->pos;
- $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
- if ($subres !== FALSE) {
- $this->store( $result, $subres, "Method" );
- }
- else { $_72 = FALSE; break; }
- $res_71 = $result;
- $pos_71 = $this->pos;
- $_70 = NULL;
- do {
- if (substr($this->string,$this->pos,1) == '(') {
- $this->pos += 1;
- $result["text"] .= '(';
- }
- else { $_70 = FALSE; break; }
- if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
- $res_67 = $result;
- $pos_67 = $this->pos;
- $matcher = 'match_'.'CallArguments'; $key = $matcher; $pos = $this->pos;
- $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
- if ($subres !== FALSE) {
- $this->store( $result, $subres, "CallArguments" );
- }
- else {
- $result = $res_67;
- $this->pos = $pos_67;
- unset( $res_67 );
- unset( $pos_67 );
- }
- if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
- if (substr($this->string,$this->pos,1) == ')') {
- $this->pos += 1;
- $result["text"] .= ')';
- }
- else { $_70 = FALSE; break; }
- $_70 = TRUE; break;
- }
- while(0);
- if( $_70 === FALSE) {
- $result = $res_71;
- $this->pos = $pos_71;
- unset( $res_71 );
- unset( $pos_71 );
- }
- $_72 = TRUE; break;
- }
- while(0);
- if( $_72 === TRUE ) { return $this->finalise($result); }
- if( $_72 === FALSE) { return FALSE; }
- }
- /* LookupStep: :Call &"." */
- protected $match_LookupStep_typestack = array('LookupStep');
- function match_LookupStep ($stack = array()) {
- $matchrule = "LookupStep"; $result = $this->construct($matchrule, $matchrule, null);
- $_76 = NULL;
- do {
- $matcher = 'match_'.'Call'; $key = $matcher; $pos = $this->pos;
- $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
- if ($subres !== FALSE) {
- $this->store( $result, $subres, "Call" );
- }
- else { $_76 = FALSE; break; }
- $res_75 = $result;
- $pos_75 = $this->pos;
- if (substr($this->string,$this->pos,1) == '.') {
- $this->pos += 1;
- $result["text"] .= '.';
- $result = $res_75;
- $this->pos = $pos_75;
- }
- else {
- $result = $res_75;
- $this->pos = $pos_75;
- $_76 = FALSE; break;
- }
- $_76 = TRUE; break;
- }
- while(0);
- if( $_76 === TRUE ) { return $this->finalise($result); }
- if( $_76 === FALSE) { return FALSE; }
- }
- /* LastLookupStep: :Call */
- protected $match_LastLookupStep_typestack = array('LastLookupStep');
- function match_LastLookupStep ($stack = array()) {
- $matchrule = "LastLookupStep"; $result = $this->construct($matchrule, $matchrule, null);
- $matcher = 'match_'.'Call'; $key = $matcher; $pos = $this->pos;
- $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
- if ($subres !== FALSE) {
- $this->store( $result, $subres, "Call" );
- return $this->finalise($result);
- }
- else { return FALSE; }
- }
- /* Lookup: LookupStep ("." LookupStep)* "." LastLookupStep | LastLookupStep */
- protected $match_Lookup_typestack = array('Lookup');
- function match_Lookup ($stack = array()) {
- $matchrule = "Lookup"; $result = $this->construct($matchrule, $matchrule, null);
- $_90 = NULL;
- do {
- $res_79 = $result;
- $pos_79 = $this->pos;
- $_87 = NULL;
- do {
- $matcher = 'match_'.'LookupStep'; $key = $matcher; $pos = $this->pos;
- $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
- if ($subres !== FALSE) { $this->store( $result, $subres ); }
- else { $_87 = FALSE; break; }
- while (true) {
- $res_84 = $result;
- $pos_84 = $this->pos;
- $_83 = NULL;
- do {
- if (substr($this->string,$this->pos,1) == '.') {
- $this->pos += 1;
- $result["text"] .= '.';
- }
- else { $_83 = FALSE; break; }
- $matcher = 'match_'.'LookupStep'; $key = $matcher; $pos = $this->pos;
- $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
- if ($subres !== FALSE) {
- $this->store( $result, $subres );
- }
- else { $_83 = FALSE; break; }
- $_83 = TRUE; break;
- }
- while(0);
- if( $_83 === FALSE) {
- $result = $res_84;
- $this->pos = $pos_84;
- unset( $res_84 );
- unset( $pos_84 );
- break;
- }
- }
- if (substr($this->string,$this->pos,1) == '.') {
- $this->pos += 1;
- $result["text"] .= '.';
- }
- else { $_87 = FALSE; break; }
- $matcher = 'match_'.'LastLookupStep'; $key = $matcher; $pos = $this->pos;
- $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
- if ($subres !== FALSE) { $this->store( $result, $subres ); }
- else { $_87 = FALSE; break; }
- $_87 = TRUE; break;
- }
- while(0);
- if( $_87 === TRUE ) { $_90 = TRUE; break; }
- $result = $res_79;
- $this->pos = $pos_79;
- $matcher = 'match_'.'LastLookupStep'; $key = $matcher; $pos = $this->pos;
- $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
- if ($subres !== FALSE) {
- $this->store( $result, $subres );
- $_90 = TRUE; break;
- }
- $result = $res_79;
- $this->pos = $pos_79;
- $_90 = FALSE; break;
- }
- while(0);
- if( $_90 === TRUE ) { return $this->finalise($result); }
- if( $_90 === FALSE) { return FALSE; }
- }
- function Lookup__construct(&$res) {
- $res['php'] = '$scope->locally()';
- $res['LookupSteps'] = array();
- }
- /**
- * The basic generated PHP of LookupStep and LastLookupStep is the same, except that LookupStep calls 'obj' to
- * get the next ViewableData in the sequence, and LastLookupStep calls different methods (XML_val, hasValue, obj)
- * depending on the context the lookup is used in.
- */
- function Lookup_AddLookupStep(&$res, $sub, $method) {
- $res['LookupSteps'][] = $sub;
- $property = $sub['Call']['Method']['text'];
- if (isset($sub['Call']['CallArguments']) && $arguments = $sub['Call']['CallArguments']['php']) {
- $res['php'] .= "->$method('$property', array($arguments), true)";
- }
- else {
- $res['php'] .= "->$method('$property', null, true)";
- }
- }
- function Lookup_LookupStep(&$res, $sub) {
- $this->Lookup_AddLookupStep($res, $sub, 'obj');
- }
- function Lookup_LastLookupStep(&$res, $sub) {
- $this->Lookup_AddLookupStep($res, $sub, '$$FINAL');
- }
- /* Translate: "<%t" < Entity < (Default:QuotedString)? < (!("is" "=") < "is" < Context:QuotedString)? <
- (InjectionVariables)? > "%>" */
- protected $match_Translate_typestack = array('Translate');
- function match_Translate ($stack = array()) {
- $matchrule = "Translate"; $result = $this->construct($matchrule, $matchrule, null);
- $_116 = NULL;
- do {
- if (( $subres = $this->literal( '<%t' ) ) !== FALSE) { $result["text"] .= $subres; }
- else { $_116 = FALSE; break; }
- if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
- $matcher = 'match_'.'Entity'; $key = $matcher; $pos = $this->pos;
- $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
- if ($subres !== FALSE) { $this->store( $result, $subres ); }
- else { $_116 = FALSE; break; }
- if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
- $res_98 = $result;
- $pos_98 = $this->pos;
- $_97 = NULL;
- do {
- $matcher = 'match_'.'QuotedString'; $key = $matcher; $pos = $this->pos;
- $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
- if ($subres !== FALSE) {
- $this->store( $result, $subres, "Default" );
- }
- else { $_97 = FALSE; break; }
- $_97 = TRUE; break;
- }
- while(0);
- if( $_97 === FALSE) {
- $result = $res_98;
- $this->pos = $pos_98;
- unset( $res_98 );
- unset( $pos_98 );
- }
- if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
- $res_109 = $result;
- $pos_109 = $this->pos;
- $_108 = NULL;
- do {
- $res_103 = $result;
- $pos_103 = $this->pos;
- $_102 = NULL;
- do {
- if (( $subres = $this->literal( 'is' ) ) !== FALSE) { $result["text"] .= $subres; }
- else { $_102 = FALSE; break; }
- if (substr($this->string,$this->pos,1) == '=') {
- $this->pos += 1;
- $result["text"] .= '=';
- }
- else { $_102 = FALSE; break; }
- $_102 = TRUE; break;
- }
- while(0);
- if( $_102 === TRUE ) {
- $result = $res_103;
- $this->pos = $pos_103;
- $_108 = FALSE; break;
- }
- if( $_102 === FALSE) {
- $result = $res_103;
- $this->pos = $pos_103;
- }
- if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
- if (( $subres = $this->literal( 'is' ) ) !== FALSE) { $result["text"] .= $subres; }
- else { $_108 = FALSE; break; }
- if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
- $matcher = 'match_'.'QuotedString'; $key = $matcher; $pos = $this->pos;
- $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
- if ($subres !== FALSE) {
- $this->store( $result, $subres, "Context" );
- }
- else { $_108 = FALSE; break; }
- $_108 = TRUE; break;
- }
- while(0);
- if( $_108 === FALSE) {
- $result = $res_109;
- $this->pos = $pos_109;
- unset( $res_109 );
- unset( $pos_109 );
- }
- if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
- $res_113 = $result;
- $pos_113 = $this->pos;
- $_112 = NULL;
- do {
- $matcher = 'match_'.'InjectionVariables'; $key = $matcher; $pos = $this->pos;
- $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
- if ($subres !== FALSE) { $this->store( $result, $subres ); }
- else { $_112 = FALSE; break; }
- $_112 = TRUE; break;
- }
- while(0);
- if( $_112 === FALSE) {
- $result = $res_113;
- $this->pos = $pos_113;
- unset( $res_113 );
- unset( $pos_113 );
- }
- if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
- if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; }
- else { $_116 = FALSE; break; }
- $_116 = TRUE; break;
- }
- while(0);
- if( $_116 === TRUE ) { return $this->finalise($result); }
- if( $_116 === FALSE) { return FALSE; }
- }
- /* InjectionVariables: (< InjectionName:Word "=" Argument)+ */
- protected $match_InjectionVariables_typestack = array('InjectionVariables');
- function match_InjectionVariables ($stack = array()) {
- $matchrule = "InjectionVariables"; $result = $this->construct($matchrule, $matchrule, null);
- $count = 0;
- while (true) {
- $res_123 = $result;
- $pos_123 = $this->pos;
- $_122 = NULL;
- do {
- if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
- $matcher = 'match_'.'Word'; $key = $matcher; $pos = $this->pos;
- $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
- if ($subres !== FALSE) {
- $this->store( $result, $subres, "InjectionName" );
- }
- else { $_122 = FALSE; break; }
- if (substr($this->string,$this->pos,1) == '=') {
- $this->pos += 1;
- $result["text"] .= '=';
- }
- else { $_122 = FALSE; break; }
- $matcher = 'match_'.'Argument'; $key = $matcher; $pos = $this->pos;
- $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
- if ($subres !== FALSE) { $this->store( $result, $subres ); }
- else { $_122 = FALSE; break; }
- $_122 = TRUE; break;
- }
- while(0);
- if( $_122 === FALSE) {
- $result = $res_123;
- $this->pos = $pos_123;
- unset( $res_123 );
- unset( $pos_123 );
- break;
- }
- $count += 1;
- }
- if ($count > 0) { return $this->finalise($result); }
- else { return FALSE; }
- }
- /* Entity: / [A-Za-z_] [\w\.]* / */
- protected $match_Entity_typestack = array('Entity');
- function match_Entity ($stack = array()) {
- $matchrule = "Entity"; $result = $this->construct($matchrule, $matchrule, null);
- if (( $subres = $this->rx( '/ [A-Za-z_] [\w\.]* /' ) ) !== FALSE) {
- $result["text"] .= $subres;
- return $this->finalise($result);
- }
- else { return FALSE; }
- }
- function Translate__construct(&$res) {
- $res['php'] = '$val .= _t(';
- }
- function Translate_Entity(&$res, $sub) {
- $res['php'] .= "'$sub[text]'";
- }
- function Translate_Default(&$res, $sub) {
- $res['php'] .= ",$sub[text]";
- }
- function Translate_Context(&$res, $sub) {
- $res['php'] .= ",$sub[text]";
- }
- function Translate_InjectionVariables(&$res, $sub) {
- $res['php'] .= ",$sub[php]";
- }
- function Translate__finalise(&$res) {
- $res['php'] .= ');';
- }
- function InjectionVariables__construct(&$res) {
- $res['php'] = "array(";
- }
- function InjectionVariables_InjectionName(&$res, $sub) {
- $res['php'] .= "'$sub[text]'=>";
- }
- function InjectionVariables_Argument(&$res, $sub) {
- $res['php'] .= str_replace('$$FINAL', 'XML_val', $sub['php']) . ',';
- }
- function InjectionVariables__finalise(&$res) {
- if (substr($res['php'], -1) == ',') $res['php'] = substr($res['php'], 0, -1); //remove last comma in the array
- $res['php'] .= ')';
- }
- /* SimpleInjection: '$' :Lookup */
- protected $match_SimpleInjection_typestack = array('SimpleInjection');
- function match_SimpleInjection ($stack = array()) {
- $matchrule = "SimpleInjection"; $result = $this->construct($matchrule, $matchrule, null);
- $_127 = NULL;
- do {
- if (substr($this->string,$this->pos,1) == '$') {
- $this->pos += 1;
- $result["text"] .= '$';
- }
- else { $_127 = FALSE; break; }
- $matcher = 'match_'.'Lookup'; $key = $matcher; $pos = $this->pos;
- $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
- if ($subres !== FALSE) {
- $this->store( $result, $subres, "Lookup" );
- }
- else { $_127 = FALSE; break; }
- $_127 = TRUE; break;
- }
- while(0);
- if( $_127 === TRUE ) { return $this->finalise($result); }
- if( $_127 === FALSE) { return FALSE; }
- }
- /* BracketInjection: '{$' :Lookup "}" */
- protected $match_BracketInjection_typestack = array('BracketInjection');
- function match_BracketInjection ($stack = array()) {
- $matchrule = "BracketInjection"; $result = $this->construct($matchrule, $matchrule, null);
- $_132 = NULL;
- do {
- if (( $subres = $this->literal( '{$' ) ) !== FALSE) { $result["text"] .= $subres; }
- else { $_132 = FALSE; break; }
- $matcher = 'match_'.'Lookup'; $key = $matcher; $pos = $this->pos;
- $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
- if ($subres !== FALSE) {
- $this->store( $result, $subres, "Lookup" );
- }
- else { $_132 = FALSE; break; }
- if (substr($this->string,$this->pos,1) == '}') {
- $this->pos += 1;
- $result["text"] .= '}';
- }
- else { $_132 = FALSE; break; }
- $_132 = TRUE; break;
- }
- while(0);
- if( $_132 === TRUE ) { return $this->finalise($result); }
- if( $_132 === FALSE) { return FALSE; }
- }
- /* Injection: BracketInjection | SimpleInjection */
- protected $match_Injection_typestack = array('Injection');
- function match_Injection ($stack = array()) {
- $matchrule = "Injection"; $result = $this->construct($matchrule, $matchrule, null);
- $_137 = NULL;
- do {
- $res_134 = $result;
- $pos_134 = $this->pos;
- $matcher = 'match_'.'BracketInjection'; $key = $matcher; $pos = $this->pos;
- $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
- if ($subres !== FALSE) {
- $this->store( $result, $subres );
- $_137 = TRUE; break;
- }
- $result = $res_134;
- $this->pos = $pos_134;
- $matcher = 'match_'.'SimpleInjection'; $key = $matcher; $pos = $this->pos;
- $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
- if ($subres !== FALSE) {
- $this->store( $result, $subres );
- $_137 = TRUE; break;
- }
- $result = $res_134;
- $this->pos = $pos_134;
- $_137 = FALSE; break;
- }
- while(0);
- if( $_137 === TRUE ) { return $this->finalise($result); }
- if( $_137 === FALSE) { return FALSE; }
- }
- function Injection_STR(&$res, $sub) {
- $res['php'] = '$val .= '. str_replace('$$FINAL', 'XML_val', $sub['Lookup']['php']) . ';';
- }
- /* DollarMarkedLookup: SimpleInjection */
- protected $match_DollarMarkedLookup_typestack = array('DollarMarkedLookup');
- function match_DollarMarkedLookup ($stack = array()) {
- $matchrule = "DollarMarkedLookup"; $result = $this->construct($matchrule, $matchrule, null);
- $matcher = 'match_'.'SimpleInjection'; $key = $matcher; $pos = $this->pos;
- $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
- if ($subres !== FALSE) {
- $this->store( $result, $subres );
- return $this->finalise($result);
- }
- else { return FALSE; }
- }
- function DollarMarkedLookup_STR(&$res, $sub) {
- $res['Lookup'] = $sub['Lookup'];
- }
- /* QuotedString: q:/['"]/ String:/ (\\\\ | \\. | [^$q\\])* / '$q' */
- protected $match_QuotedString_typestack = array('QuotedString');
- function match_QuotedString ($stack = array()) {
- $matchrule = "QuotedString"; $result = $this->construct($matchrule, $matchrule, null);
- $_143 = NULL;
- do {
- $stack[] = $result; $result = $this->construct( $matchrule, "q" );
- if (( $subres = $this->rx( '/[\'"]/' ) ) !== FALSE) {
- $result["text"] .= $subres;
- $subres = $result; $result = array_pop($stack);
- $this->store( $result, $subres, 'q' );
- }
- else {
- $result = array_pop($stack);
- $_143 = FALSE; break;
- }
- $stack[] = $result; $result = $this->construct( $matchrule, "String" );
- if (( $subres = $this->rx( '/ (\\\\\\\\ | \\\\. | [^'.$this->expression($result, $stack, 'q').'\\\\])* /' ) ) !== FALSE) {
- $result["text"] .= $subres;
- $subres = $result; $result = array_pop($stack);
- $this->store( $result, $subres, 'String' );
- }
- else {
- $result = array_pop($stack);
- $_143 = FALSE; break;
- }
- if (( $subres = $this->literal( ''.$this->expression($result, $stack, 'q').'' ) ) !== FALSE) { $result["text"] .= $subres; }
- else { $_143 = FALSE; break; }
- $_143 = TRUE; break;
- }
- while(0);
- if( $_143 === TRUE ) { return $this->finalise($result); }
- if( $_143 === FALSE) { return FALSE; }
- }
- /* FreeString: /[^,)%!=><|&]+/ */
- protected $match_FreeString_typestack = array('FreeString');
- function match_FreeString ($stack = array()) {
- $matchrule = "FreeString"; $result = $this->construct($matchrule, $matchrule, null);
- if (( $subres = $this->rx( '/[^,)%!=><|&]+/' ) ) !== FALSE) {
- $result["text"] .= $subres;
- return $this->finalise($result);
- }
- else { return FALSE; }
- }
- /* Argument:
- :DollarMarkedLookup |
- :QuotedString |
- :Lookup !(< FreeString)|
- :FreeString */
- protected $match_Argument_typestack = array('Argument');
- function match_Argument ($stack = array()) {
- $matchrule = "Argument"; $result = $this->construct($matchrule, $matchrule, null);
- $_163 = NULL;
- do {
- $res_146 = $result;
- $pos_146 = $this->pos;
- $matcher = 'match_'.'DollarMarkedLookup'; $key = $matcher; $pos = $this->pos;
- $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
- if ($subres !== FALSE) {
- $this->store( $result, $subres, "DollarMarkedLookup" );
- $_163 = TRUE; break;
- }
- $result = $res_146;
- $this->pos = $pos_146;
- $_161 = NULL;
- do {
- $res_148 = $result;
- $pos_148 = $this->pos;
- $matcher = 'match_'.'QuotedString'; $key = $matcher; $pos = $this->pos;
- $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
- if ($subres !== FALSE) {
- $this->store( $result, $subres, "QuotedString" );
- $_161 = TRUE; break;
- }
- $result = $res_148;
- $this->pos = $pos_148;
- $_159 = NULL;
- do {
- $res_150 = $result;
- $pos_150 = $this->pos;
- $_156 = NULL;
- do {
- $matcher = 'match_'.'Lookup'; $key = $matcher; $pos = $this->pos;
- $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
- if ($subres !== FALSE) {
- $this->store( $result, $subres, "Lookup" );
- }
- else { $_156 = FALSE; break; }
- $res_155 = $result;
- $pos_155 = $this->pos;
- $_154 = NULL;
- do {
- if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
- $matcher = 'match_'.'FreeString'; $key = $matcher; $pos = $this->pos;
- $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
- if ($subres !== FALSE) {
- $this->store( $result, $subres );
- }
- else { $_154 = FALSE; break; }
- $_154 = TRUE; break;
- }
- while(0);
- if( $_154 === TRUE ) {
- $result = $res_155;
- $this->pos = $pos_155;
- $_156 = FALSE; break;
- }
- if( $_154 === FALSE) {
- $result = $res_155;
- $this->pos = $pos_155;
- }
- $_156 = TRUE; break;
- }
- while(0);
- if( $_156 === TRUE ) { $_159 = TRUE; break; }
- $result = $res_150;
- $this->pos = $pos_150;
- $matcher = 'match_'.'FreeString'; $key = $matcher; $pos = $this->pos;
- $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
- if ($subres !== FALSE) {
- $this->store( $result, $subres, "FreeString" );
- $_159 = TRUE; break;
- }
- $result = $res_150;
- $this->pos = $pos_150;
- $_159 = FALSE; break;
- }
- while(0);
- if( $_159 === TRUE ) { $_161 = TRUE; break; }
- $result = $res_148;
- $this->pos = $pos_148;
- $_161 = FALSE; break;
- }
- while(0);
- if( $_161 === TRUE ) { $_163 = TRUE; break; }
- $result = $res_146;
- $this->pos = $pos_146;
- $_163 = FALSE; break;
- }
- while(0);
- if( $_163 === TRUE ) { return $this->finalise($result); }
- if( $_163 === FALSE) { return FALSE; }
- }
- /**
- * If we get a bare value, we don't know enough to determine exactly what php would be the translation, because
- * we don't know if the position of use indicates a lookup or a string argument.
- *
- * Instead, we record 'ArgumentMode' as a member of this matches results node, which can be:
- * - lookup if this argument was unambiguously a lookup (marked as such)
- * - string is this argument was unambiguously a string (marked as such, or impossible to parse as lookup)
- * - default if this argument needs to be handled as per 2.4
- *
- * In the case of 'default', there is no php member of the results node, but instead 'lookup_php', which
- * should be used by the parent if the context indicates a lookup, and 'string_php' which should be used
- * if the context indicates a string
- */
- function Argument_DollarMarkedLookup(&$res, $sub) {
- $res['ArgumentMode'] = 'lookup';
- $res['php'] = $sub['Lookup']['php'];
- }
- function Argument_QuotedString(&$res, $sub) {
- $res['ArgumentMode'] = 'string';
- $res['php'] = "'" . str_replace("'", "\\'", $sub['String']['text']) . "'";
- }
- function Argument_Lookup(&$res, $sub) {
- if (count($sub['LookupSteps']) == 1 && !isset($sub['LookupSteps'][0]['Call']['Arguments'])) {
- $res['ArgumentMode'] = 'default';
- $res['lookup_php'] = $sub['php'];
- $res['string_php'] = "'".$sub['LookupSteps'][0]['Call']['Method']['text']."'";
- }
- else {
- $res['ArgumentMode'] = 'lookup';
- $res['php'] = $sub['php'];
- }
- }
- function Argument_FreeString(&$res, $sub) {
- $res['ArgumentMode'] = 'string';
- $res['php'] = "'" . str_replace("'", "\\'", trim($sub['text'])) . "'";
- }
- /* ComparisonOperator: "!=" | "==" | ">=" | ">" | "<=" | "<" | "=" */
- protected $match_ComparisonOperator_typestack = array('ComparisonOperator');
- function match_ComparisonOperator ($stack = array()) {
- $matchrule = "ComparisonOperator"; $result = $this->construct($matchrule, $matchrule, null);
- $_188 = NULL;
- do {
- $res_165 = $result;
- $pos_165 = $this->pos;
- if (( $subres = $this->literal( '!=' ) ) !== FALSE) {
- $result["text"] .= $subres;
- $_188 = TRUE; break;
- }
- $result = $res_165;
- $this->pos = $pos_165;
- $_186 = NULL;
- do {
- $res_167 = $result;
- $pos_167 = $this->pos;
- if (( $subres = $this->literal( '==' ) ) !== FALSE) {
- $result["text"] .= $subres;
- $_186 = TRUE; break;
- }
- $result = $res_167;
- $this->pos = $pos_167;
- $_184 = NULL;
- do {
- $res_169 = $result;
- $pos_169 = $this->pos;
- if (( $subres = $this->literal( '>=' ) ) !== FALSE) {
- $result["text"] .= $subres;
- $_184 = TRUE; break;
- }
- $result = $res_169;
- $this->pos = $pos_169;
- $_182 = NULL;
- do {
- $res_171 = $result;
- $pos_171 = $this->pos;
- if (substr($this->string,$this->pos,1) == '>') {
- $this->pos += 1;
- $result["text"] .= '>';
- $_182 = TRUE; break;
- }
- $result = $res_171;
- $this->pos = $pos_171;
- $_180 = NULL;
- do {
- $res_173 = $result;
- $pos_173 = $this->pos;
- if (( $subres = $this->literal( '<=' ) ) !== FALSE) {
- $result["text"] .= $subres;
- $_180 = TRUE; break;
- }
- $result = $res_173;
- $this->pos = $pos_173;
- $_178 = NULL;
- do {
- $res_175 = $result;
- $pos_175 = $this->pos;
- if (substr($this->string,$this->pos,1) == '<') {
- $this->pos += 1;
- $result["text"] .= '<';
- $_178 = TRUE; break;
- }
- $result = $res_175;
- $this->pos = $pos_175;
- if (substr($this->string,$this->pos,1) == '=') {
- $this->pos += 1;
- $result["text"] .= '=';
- $_178 = TRUE; break;
- }
- $result = $res_175;
- $this->pos = $pos_175;
- $_178 = FALSE; break;
- }
- while(0);
- if( $_178 === TRUE ) { $_180 = TRUE; break; }
- $result = $res_173;
- $this->pos = $pos_173;
- $_180 = FALSE; break;
- }
- while(0);
- if( $_180 === TRUE ) { $_182 = TRUE; break; }
- $result = $res_171;
- $this->pos = $pos_171;
- $_182 = FALSE; break;
- }
- while(0);
- if( $_182 === TRUE ) { $_184 = TRUE; break; }
- $result = $res_169;
- $this->pos = $pos_169;
- $_184 = FALSE; break;
- }
- while(0);
- if( $_184 === TRUE ) { $_186 = TRUE; break; }
- $result = $res_167;
- $this->pos = $pos_167;
- $_186 = FALSE; break;
- }
- while(0);
- if( $_186 === TRUE ) { $_188 = TRUE; break; }
- $result = $res_165;
- $this->pos = $pos_165;
- $_188 = FALSE; break;
- }
- while(0);
- if( $_188 === TRUE ) { return $this->finalise($result); }
- if( $_188 === FALSE) { return FALSE; }
- }
- /* Comparison: Argument < ComparisonOperator > Argument */
- protected $match_Comparison_typestack = array('Comparison');
- function match_Comparison ($stack = array()) {
- $matchrule = "Comparison"; $result = $this->construct($matchrule, $matchrule, null);
- $_195 = NULL;
- do {
- $matcher = 'match_'.'Argument'; $key = $matcher; $pos = $this->pos;
- $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
- if ($subres !== FALSE) { $this->store( $result, $subres ); }
- else { $_195 = FALSE; break; }
- if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
- $matcher = 'match_'.'ComparisonOperator'; $key = $matcher; $pos = $this->pos;
- $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
- if ($subres !== FALSE) { $this->store( $result, $subres ); }
- else { $_195 = FALSE; break; }
- if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
- $matcher = 'match_'.'Argument'; $key = $matcher; $pos = $this->pos;
- $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
- if ($subres !== FALSE) { $this->store( $result, $subres ); }
- else { $_195 = …
Large files files are truncated, but you can click here to view the full file