/view/SSTemplateParser.php
PHP | 3951 lines | 3582 code | 201 blank | 168 comment | 618 complexity | e85fd4c3b23fac26549bbffc974166fe MD5 | raw file
Possible License(s): MIT, BSD-3-Clause, CC-BY-3.0, GPL-2.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 THIRDPARTY_PATH . '/php-peg/Parser.php' ;
- }
- else {
- $base = dirname(__FILE__);
- require $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.
- */
- 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
- */
- class SSTemplateParser extends Parser {
- /**
- * @var bool - Set true by SSTemplateParser::compileString if the template should include comments intended
- * for debugging (template source, included files, etc)
- */
- protected $includeDebuggingComments = false;
-
- /**
- * 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;
- }
-
- /* Template: (Comment | If | Require | CacheBlock | UncachedBlock | OldI18NTag | 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_42 = $result;
- $pos_42 = $this->pos;
- $_41 = NULL;
- do {
- $_39 = 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 );
- $_39 = TRUE; break;
- }
- $result = $res_0;
- $this->pos = $pos_0;
- $_37 = NULL;
- do {
- $res_2 = $result;
- $pos_2 = $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 );
- $_37 = TRUE; break;
- }
- $result = $res_2;
- $this->pos = $pos_2;
- $_35 = NULL;
- do {
- $res_4 = $result;
- $pos_4 = $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 );
- $_35 = TRUE; break;
- }
- $result = $res_4;
- $this->pos = $pos_4;
- $_33 = NULL;
- do {
- $res_6 = $result;
- $pos_6 = $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 );
- $_33 = TRUE; break;
- }
- $result = $res_6;
- $this->pos = $pos_6;
- $_31 = NULL;
- do {
- $res_8 = $result;
- $pos_8 = $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 );
- $_31 = TRUE; break;
- }
- $result = $res_8;
- $this->pos = $pos_8;
- $_29 = NULL;
- do {
- $res_10 = $result;
- $pos_10 = $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 );
- $_29 = TRUE; break;
- }
- $result = $res_10;
- $this->pos = $pos_10;
- $_27 = NULL;
- do {
- $res_12 = $result;
- $pos_12 = $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 );
- $_27 = TRUE; break;
- }
- $result = $res_12;
- $this->pos = $pos_12;
- $_25 = NULL;
- do {
- $res_14 = $result;
- $pos_14 = $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 );
- $_25 = TRUE; break;
- }
- $result = $res_14;
- $this->pos = $pos_14;
- $_23 = NULL;
- do {
- $res_16 = $result;
- $pos_16 = $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 );
- $_23 = TRUE; break;
- }
- $result = $res_16;
- $this->pos = $pos_16;
- $_21 = NULL;
- do {
- $res_18 = $result;
- $pos_18 = $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 );
- $_21 = TRUE; break;
- }
- $result = $res_18;
- $this->pos = $pos_18;
- $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 );
- $_21 = TRUE; break;
- }
- $result = $res_18;
- $this->pos = $pos_18;
- $_21 = FALSE; break;
- }
- while(0);
- if( $_21 === TRUE ) { $_23 = TRUE; break; }
- $result = $res_16;
- $this->pos = $pos_16;
- $_23 = FALSE; break;
- }
- while(0);
- if( $_23 === TRUE ) { $_25 = TRUE; break; }
- $result = $res_14;
- $this->pos = $pos_14;
- $_25 = FALSE; break;
- }
- while(0);
- if( $_25 === TRUE ) { $_27 = TRUE; break; }
- $result = $res_12;
- $this->pos = $pos_12;
- $_27 = FALSE; break;
- }
- while(0);
- if( $_27 === TRUE ) { $_29 = TRUE; break; }
- $result = $res_10;
- $this->pos = $pos_10;
- $_29 = FALSE; break;
- }
- while(0);
- if( $_29 === TRUE ) { $_31 = TRUE; break; }
- $result = $res_8;
- $this->pos = $pos_8;
- $_31 = FALSE; break;
- }
- while(0);
- if( $_31 === TRUE ) { $_33 = TRUE; break; }
- $result = $res_6;
- $this->pos = $pos_6;
- $_33 = FALSE; break;
- }
- while(0);
- if( $_33 === TRUE ) { $_35 = TRUE; break; }
- $result = $res_4;
- $this->pos = $pos_4;
- $_35 = FALSE; break;
- }
- while(0);
- if( $_35 === TRUE ) { $_37 = TRUE; break; }
- $result = $res_2;
- $this->pos = $pos_2;
- $_37 = FALSE; break;
- }
- while(0);
- if( $_37 === TRUE ) { $_39 = TRUE; break; }
- $result = $res_0;
- $this->pos = $pos_0;
- $_39 = FALSE; break;
- }
- while(0);
- if( $_39 === FALSE) { $_41 = FALSE; break; }
- $_41 = TRUE; break;
- }
- while(0);
- if( $_41 === FALSE) {
- $result = $res_42;
- $this->pos = $pos_42;
- unset( $res_42 );
- unset( $pos_42 );
- 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; }
- }
- /* 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);
- $_53 = 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 { $_53 = FALSE; break; }
- while (true) {
- $res_52 = $result;
- $pos_52 = $this->pos;
- $_51 = NULL;
- do {
- if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
- if (substr($this->string,$this->pos,1) == ',') {
- $this->pos += 1;
- $result["text"] .= ',';
- }
- else { $_51 = 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 { $_51 = FALSE; break; }
- $_51 = TRUE; break;
- }
- while(0);
- if( $_51 === FALSE) {
- $result = $res_52;
- $this->pos = $pos_52;
- unset( $res_52 );
- unset( $pos_52 );
- break;
- }
- }
- $_53 = TRUE; break;
- }
- while(0);
- if( $_53 === TRUE ) { return $this->finalise($result); }
- if( $_53 === 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);
- $_63 = 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 { $_63 = FALSE; break; }
- $res_62 = $result;
- $pos_62 = $this->pos;
- $_61 = NULL;
- do {
- if (substr($this->string,$this->pos,1) == '(') {
- $this->pos += 1;
- $result["text"] .= '(';
- }
- else { $_61 = FALSE; break; }
- if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
- $res_58 = $result;
- $pos_58 = $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_58;
- $this->pos = $pos_58;
- unset( $res_58 );
- unset( $pos_58 );
- }
- if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
- if (substr($this->string,$this->pos,1) == ')') {
- $this->pos += 1;
- $result["text"] .= ')';
- }
- else { $_61 = FALSE; break; }
- $_61 = TRUE; break;
- }
- while(0);
- if( $_61 === FALSE) {
- $result = $res_62;
- $this->pos = $pos_62;
- unset( $res_62 );
- unset( $pos_62 );
- }
- $_63 = TRUE; break;
- }
- while(0);
- if( $_63 === TRUE ) { return $this->finalise($result); }
- if( $_63 === FALSE) { return FALSE; }
- }
- /* LookupStep: :Call &"." */
- protected $match_LookupStep_typestack = array('LookupStep');
- function match_LookupStep ($stack = array()) {
- $matchrule = "LookupStep"; $result = $this->construct($matchrule, $matchrule, null);
- $_67 = 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 { $_67 = FALSE; break; }
- $res_66 = $result;
- $pos_66 = $this->pos;
- if (substr($this->string,$this->pos,1) == '.') {
- $this->pos += 1;
- $result["text"] .= '.';
- $result = $res_66;
- $this->pos = $pos_66;
- }
- else {
- $result = $res_66;
- $this->pos = $pos_66;
- $_67 = FALSE; break;
- }
- $_67 = TRUE; break;
- }
- while(0);
- if( $_67 === TRUE ) { return $this->finalise($result); }
- if( $_67 === 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);
- $_81 = NULL;
- do {
- $res_70 = $result;
- $pos_70 = $this->pos;
- $_78 = 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 { $_78 = FALSE; break; }
- while (true) {
- $res_75 = $result;
- $pos_75 = $this->pos;
- $_74 = NULL;
- do {
- if (substr($this->string,$this->pos,1) == '.') {
- $this->pos += 1;
- $result["text"] .= '.';
- }
- else { $_74 = 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 { $_74 = FALSE; break; }
- $_74 = TRUE; break;
- }
- while(0);
- if( $_74 === FALSE) {
- $result = $res_75;
- $this->pos = $pos_75;
- unset( $res_75 );
- unset( $pos_75 );
- break;
- }
- }
- if (substr($this->string,$this->pos,1) == '.') {
- $this->pos += 1;
- $result["text"] .= '.';
- }
- else { $_78 = 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 { $_78 = FALSE; break; }
- $_78 = TRUE; break;
- }
- while(0);
- if( $_78 === TRUE ) { $_81 = TRUE; break; }
- $result = $res_70;
- $this->pos = $pos_70;
- $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 );
- $_81 = TRUE; break;
- }
- $result = $res_70;
- $this->pos = $pos_70;
- $_81 = FALSE; break;
- }
- while(0);
- if( $_81 === TRUE ) { return $this->finalise($result); }
- if( $_81 === FALSE) { return FALSE; }
- }
-
- function Lookup__construct(&$res) {
- $res['php'] = '$scope';
- $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');
- }
- /* SimpleInjection: '$' :Lookup */
- protected $match_SimpleInjection_typestack = array('SimpleInjection');
- function match_SimpleInjection ($stack = array()) {
- $matchrule = "SimpleInjection"; $result = $this->construct($matchrule, $matchrule, null);
- $_85 = NULL;
- do {
- if (substr($this->string,$this->pos,1) == '$') {
- $this->pos += 1;
- $result["text"] .= '$';
- }
- else { $_85 = 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 { $_85 = FALSE; break; }
- $_85 = TRUE; break;
- }
- while(0);
- if( $_85 === TRUE ) { return $this->finalise($result); }
- if( $_85 === FALSE) { return FALSE; }
- }
- /* BracketInjection: '{$' :Lookup "}" */
- protected $match_BracketInjection_typestack = array('BracketInjection');
- function match_BracketInjection ($stack = array()) {
- $matchrule = "BracketInjection"; $result = $this->construct($matchrule, $matchrule, null);
- $_90 = NULL;
- do {
- if (( $subres = $this->literal( '{$' ) ) !== FALSE) { $result["text"] .= $subres; }
- else { $_90 = 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 { $_90 = FALSE; break; }
- if (substr($this->string,$this->pos,1) == '}') {
- $this->pos += 1;
- $result["text"] .= '}';
- }
- else { $_90 = FALSE; break; }
- $_90 = TRUE; break;
- }
- while(0);
- if( $_90 === TRUE ) { return $this->finalise($result); }
- if( $_90 === 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);
- $_95 = NULL;
- do {
- $res_92 = $result;
- $pos_92 = $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 );
- $_95 = TRUE; break;
- }
- $result = $res_92;
- $this->pos = $pos_92;
- $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 );
- $_95 = TRUE; break;
- }
- $result = $res_92;
- $this->pos = $pos_92;
- $_95 = FALSE; break;
- }
- while(0);
- if( $_95 === TRUE ) { return $this->finalise($result); }
- if( $_95 === 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);
- $_101 = 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);
- $_101 = 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);
- $_101 = FALSE; break;
- }
- if (( $subres = $this->literal( ''.$this->expression($result, $stack, 'q').'' ) ) !== FALSE) { $result["text"] .= $subres; }
- else { $_101 = FALSE; break; }
- $_101 = TRUE; break;
- }
- while(0);
- if( $_101 === TRUE ) { return $this->finalise($result); }
- if( $_101 === 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);
- $_121 = NULL;
- do {
- $res_104 = $result;
- $pos_104 = $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" );
- $_121 = TRUE; break;
- }
- $result = $res_104;
- $this->pos = $pos_104;
- $_119 = NULL;
- do {
- $res_106 = $result;
- $pos_106 = $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" );
- $_119 = TRUE; break;
- }
- $result = $res_106;
- $this->pos = $pos_106;
- $_117 = NULL;
- do {
- $res_108 = $result;
- $pos_108 = $this->pos;
- $_114 = 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 { $_114 = FALSE; break; }
- $res_113 = $result;
- $pos_113 = $this->pos;
- $_112 = 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 { $_112 = FALSE; break; }
- $_112 = TRUE; break;
- }
- while(0);
- if( $_112 === TRUE ) {
- $result = $res_113;
- $this->pos = $pos_113;
- $_114 = FALSE; break;
- }
- if( $_112 === FALSE) {
- $result = $res_113;
- $this->pos = $pos_113;
- }
- $_114 = TRUE; break;
- }
- while(0);
- if( $_114 === TRUE ) { $_117 = TRUE; break; }
- $result = $res_108;
- $this->pos = $pos_108;
- $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" );
- $_117 = TRUE; break;
- }
- $result = $res_108;
- $this->pos = $pos_108;
- $_117 = FALSE; break;
- }
- while(0);
- if( $_117 === TRUE ) { $_119 = TRUE; break; }
- $result = $res_106;
- $this->pos = $pos_106;
- $_119 = FALSE; break;
- }
- while(0);
- if( $_119 === TRUE ) { $_121 = TRUE; break; }
- $result = $res_104;
- $this->pos = $pos_104;
- $_121 = FALSE; break;
- }
- while(0);
- if( $_121 === TRUE ) { return $this->finalise($result); }
- if( $_121 === 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("'", "\\'", $sub['text']) . "'";
- }
-
- /* ComparisonOperator: "==" | "!=" | "=" */
- protected $match_ComparisonOperator_typestack = array('ComparisonOperator');
- function match_ComparisonOperator ($stack = array()) {
- $matchrule = "ComparisonOperator"; $result = $this->construct($matchrule, $matchrule, null);
- $_130 = NULL;
- do {
- $res_123 = $result;
- $pos_123 = $this->pos;
- if (( $subres = $this->literal( '==' ) ) !== FALSE) {
- $result["text"] .= $subres;
- $_130 = TRUE; break;
- }
- $result = $res_123;
- $this->pos = $pos_123;
- $_128 = NULL;
- do {
- $res_125 = $result;
- $pos_125 = $this->pos;
- if (( $subres = $this->literal( '!=' ) ) !== FALSE) {
- $result["text"] .= $subres;
- $_128 = TRUE; break;
- }
- $result = $res_125;
- $this->pos = $pos_125;
- if (substr($this->string,$this->pos,1) == '=') {
- $this->pos += 1;
- $result["text"] .= '=';
- $_128 = TRUE; break;
- }
- $result = $res_125;
- $this->pos = $pos_125;
- $_128 = FALSE; break;
- }
- while(0);
- if( $_128 === TRUE ) { $_130 = TRUE; break; }
- $result = $res_123;
- $this->pos = $pos_123;
- $_130 = FALSE; break;
- }
- while(0);
- if( $_130 === TRUE ) { return $this->finalise($result); }
- if( $_130 === 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);
- $_137 = 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 { $_137 = 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 { $_137 = 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 { $_137 = FALSE; break; }
- $_137 = TRUE; break;
- }
- while(0);
- if( $_137 === TRUE ) { return $this->finalise($result); }
- if( $_137 === FALSE) { return FALSE; }
- }
- function Comparison_Argument(&$res, $sub) {
- if ($sub['ArgumentMode'] == 'default') {
- if (!empty($res['php'])) $res['php'] .= $sub['string_php'];
- else $res['php'] = str_replace('$$FINAL', 'XML_val', $sub['lookup_php']);
- }
- else {
- $res['php'] .= str_replace('$$FINAL', 'XML_val', $sub['php']);
- }
- }
- function Comparison_ComparisonOperator(&$res, $sub) {
- $res['php'] .= ($sub['text'] == '=' ? '==' : $sub['text']);
- }
- /* PresenceCheck: (Not:'not' <)? Argument */
- protected $match_PresenceCheck_typestack = array('PresenceCheck');
- function match_PresenceCheck ($stack = array()) {
- $matchrule = "PresenceCheck"; $result = $this->construct($matchrule, $matchrule, null);
- $_144 = NULL;
- do {
- $res_142 = $result;
- $pos_142 = $this->pos;
- $_141 = NULL;
- do {
- $stack[] = $result; $result = $this->construct( $matchrule, "Not" );
- if (( $subres = $this->literal( 'not' ) ) !== FALSE) {
- $result["text"] .= $subres;
- $subres = $result; $result = array_pop($stack);
- $this->store( $result, $subres, 'Not' );
- }
- else {
- $result = array_pop($stack);
- $_141 = FALSE; break;
- }
- if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
- $_141 = TRUE; break;
- }
- while(0);
- if( $_141 === FALSE) {
- $result = $res_142;
- $this->pos = $pos_142;
- unset( $res_142 );
- unset( $pos_142 );
- }
- $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 { $_144 = FALSE; break; }
- $_144 = TRUE; break;
- }
- while(0);
- if( $_144 === TRUE ) { return $this->finalise($result); }
- if( $_144 === FALSE) { return FALSE; }
- }
- function PresenceCheck_Not(&$res, $sub) {
- $res['php'] = '!';
- }
-
- function PresenceCheck_Argument(&$res, $sub) {
- if ($sub['ArgumentMode'] == 'string') {
- $res['php'] .= '((bool)'.$sub['php'].')';
- }
- else {
- $php = ($sub['ArgumentMode'] == 'default' ? $sub['lookup_php'] : $sub['php']);
- // TODO: kinda hacky - maybe we need a way to pass state down the parse chain so
- // Lookup_LastLookupStep and Argument_BareWord can produce hasValue instead of XML_val
- $res['php'] .= str_replace('$$FINAL', 'hasValue', $php);
- }
- }
- /* IfArgumentPortion: Comparison | PresenceCheck */
- protected $match_IfArgumentPortion_typestack = array('IfArgumentPortion');
- function match_IfArgumentPortion ($stack = array()) {
- $matchrule = "IfArgumentPortion"; $result = $this->construct($matchrule, $matchrule, null);
- $_149 = NULL;
- do {
- $res_146 = $result;
- $pos_146 = $this->pos;
- $matcher = 'match_'.'Comparison'; $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 );
- $_149 = TRUE; break;
- }
- $result = $res_146;
- $this->pos = $pos_146;
- $matcher = 'match_'.'PresenceCheck'; $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 );
- $_149 = TRUE; break;
- }
- $result = $res_146;
- $this->pos = $pos_146;
- $_149 = FALSE; break;
- }
- while(0);
- if( $_149 === TRUE ) { return $this->finalise($result); }
- if( $_149 === FALSE) { return FALSE; }
- }
- function IfArgumentPortion_STR(&$res, $sub) {
- $res['php'] = $sub['php'];
- }
- /* BooleanOperator: "||" | "&&" */
- protected $match_BooleanOperator_typestack = array('BooleanOperator');
- function match_BooleanOperator ($stack = array()) {
- $matchrule = "BooleanOperator"; $result = $this->construct($matchrule, $matchrule, null);
- $_154 = NULL;
- do {
- $res_151 = $result;
- $pos_151 = $this->pos;
- if (( $subres = $this->literal( '||' ) ) !== FALSE) {
- $result["text"] .= $subres;
- $_154 = TRUE; break;
- }
- $result = $res_151;
- $this->pos = $pos_151;
- if (( $subres = $this->literal( '&&' ) ) !== FALSE) {
- $result["text"] .= $subres;
- $_154 = TRUE; break;
- }
- $result = $res_151;
- $this->pos = $pos_151;
- $_154 = FALSE; break;
- }
- while(0);
- if( $_154 === TRUE ) { return $this->finalise($result); }
- if( $_154 === FALSE) { return FALSE; }
- }
- /* IfArgument: :IfArgumentPortion ( < :BooleanOperator < :IfArgumentPortion )* */
- protected $match_IfArgument_typestack = array('IfArgument');
- function match_IfArgument ($stack = array()) {
- $matchrule = "IfArgument"; $result = $this->construct($matchrule, $matchrule, null);
- $_163 = NULL;
- do {
- $matcher = 'match_'.'IfArgumentPortion'; $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, "IfArgumentPortion" );
- }
- else { $_163 = FALSE; break; }
- while (true) {
- $res_162 = $result;
- $pos_162 = $this->pos;
- $_161 = NULL;
- do {
- if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
- $matcher = 'match_'.'BooleanOperator'; $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, "BooleanOperator" );
- }
- else { $_161 = FALSE; break; }
- if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
- $matcher = 'match_'.'IfArgumentPortion'; $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, "IfArgumentPortion" );
- }
- else { $_161 = FALSE; break; }
- $_161 = TRUE; break;
- }
- while(0);
- if( $_161 === FALSE) {
- $result = $res_162;
- $this->pos = $pos_162;
- unset( $res_162 );
- unset( $pos_162 );
- break;
- }
- }
- $_163 = TRUE; break;
- }
- while(0);
- if( $_163 === TRUE ) { return $this->finalise($result); }
- if( $_163 === FALSE) { return FALSE; }
- }
- function IfArgument_IfArgumentPortion(&$res, $sub) {
- $res['php'] .= $sub['php'];
- }
- function IfArgument_BooleanOperator(&$res, $sub) {
- $res['php'] .= $sub['text'];
- }
- /* IfPart: '<%' < 'if' [ :IfArgument > '%>' Template:$TemplateMatcher? */
- protected $match_IfPart_typestack = array('IfPart');
- function match_IfPart ($stack = array()) {
- $matchrule = "IfPart"; $result = $this->construct($matchrule, $matchrule, null);
- $_173 = NULL;
- do {
- if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; }
- else { $_173 = FALSE; break; }
- if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
- if (( $subres = $this->literal( 'if' ) ) !== FALSE) { $result["text"] .= $subres; }
- else { $_173 = FALSE; break; }
- if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
- else { $_173 = FALSE; break; }
- $matcher = 'match_'.'IfArgument'; $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, "IfArgument" );
- }
- else { $_173 = FALSE; break; }
- if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
- if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; }
- else { $_173 = FALSE; break; }
- $res_172 = $result;
- $pos_172 = $this->pos;
- $matcher = 'match_'.$this->expression($result, $stack, 'TemplateMatcher'); $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, "Template" );
- }
- else {
- $result = $res_172;
- $this->pos = $pos_172;
- unset( $res_172 );
- unset( $pos_172 );
- }
- $_173 = TRUE; break;
- }
- while(0);
- if( $_173 === TRUE ) { return $this->finalise($result); }
- if( $_173 === FALSE) { return FALSE; }
- }
- /* ElseIfPart: '<%' < 'else_if' [ :IfArgument > '%>' Template:$TemplateMatcher */
- protected $match_ElseIfPart_typestack = array('ElseIfPart');
- function match_ElseIfPart ($stack = array()) {
- $matchrule = "ElseIfPart"; $result = $this->construct($matchrule, $matchrule, null);
- $_183 = NULL;
- do {
- if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; }
- else { $_183 = FALSE; break; }
- if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
- if (( $subres = $this->literal( 'else_if' ) ) !== FALSE) { $result["text"] .= $subres; }
- else { $_183 = FALSE; break; }
- if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
- else { $_183 = FALSE; break; }
- $matcher = 'match_'.'IfArgument'; $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, "IfArgument" );
- }
- else { $_183 = FALSE; break; }
- if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
- if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; }
- else { $_183 = FALSE; break; }
- $matcher = 'match_'.$this->expression($result, $stack, 'TemplateMatcher'); $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, "Template" );
- }
- else { $_183 = FALSE; break; }
- $_183 = TRUE; break;
- }
- while(0);
- if( $_183 === TRUE ) { return $this->finalise($result); }
- if( $_183 === FALSE) { return FALSE; }
- }
- /* ElsePart: '<%' < 'else' > '%>' Template:$TemplateMatcher */
- protected $match_ElsePart_typestack = array('ElsePart');
- function match_ElsePart ($stack = array()) {
- $matchrule = "ElsePart"; $result = $this->construct($matchrule, $matchrule, null);
- $_191 = NULL;
- do {
- if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; }
- else { $_191 = FALSE; break; }
- if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
- if (( $subres = $this->literal( 'else' ) ) !== FALSE) { $result["text"] .= $subres; }
- else { $_191 = FALSE; break; }
- if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
- if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; }
- else { $_191 = FALSE; break; }
- $matcher = 'match_'.$this->expression($result, $stack, 'TemplateMatcher'); $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, "Template" );
- }
- else { $_191 = FALSE; break; }
- $_191 = TRUE; break;
- }
- while(0);
- if( $_191 === TRUE ) { return $this->finalise($result); }
- if( $_191 === FALSE) { return FALSE; }
- }
- /* If: IfPart ElseIfPart* ElsePart? '<%' < 'end_if' > '%>' */
- protected $match_If_typestack = array('If');
- function match_If ($stack = array()) {
- $matchrule = "If"; $result = $this->construct($matchrule, $matchrule, null);
- $_201 = NULL;
- do {
- $matcher = 'match_'.'IfPart'; $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 { $_201 = FALSE; break; }
- while (true) {
- $res_194 = $result;
- $pos_194 = $this->pos;
- $matcher = 'match_'.'ElseIfPart'; $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 {
- $result = $res_194;
- $this->pos = $pos_194;
- unset( $res_194 );
- unset( $pos_194 );
- break;
- }
- }
- $res_195 = $result;
- $pos_195 = $this->pos;
- $matcher = 'match_'.'ElsePart'; $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 {
- $result = $res_195;
- $this->pos = $pos_195;
- unset( $res_195 );
- unset( $pos_195 );
- }
- if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; }
- else { $_201 = FALSE; break; }
- if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
- if (( $subres = $this->literal( 'end_if' ) ) !== FALSE) { $result["text"] .= $subres; }
- else { $_201 = FALSE; break; }
- if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
- if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; }
- else { $_201 = FALSE; break; }
- $_201 = TRUE; break;
- }
- while(0);
- if( $_201 === TRUE ) { return $this->finalise($result); }
- if( $_201 === FALSE) { return FALSE; }
- }
- function If_IfPart(&$res, $sub) {
- $res['php'] =
- 'if (' . $sub['IfArgument']['php'] . ') { ' . PHP_EOL .
- (isset($sub['Template']) ? $sub['Template']['php'] : '') . PHP_EOL .
- '}';
- }
- function If_ElseIfPart(&$res, $sub) {
- $res['php'] .=
- 'else if (' . $sub['IfArgument']['php'] . ') { ' . PHP_EOL .
- $sub['Template']['php'] . PHP_EOL .
- '}';
- }
- func…
Large files files are truncated, but you can click here to view the full file