Open Power Template 2.x family
PLEASE PROVIDE THE TEMPLATES AND/OR PHP CODE IN THE TASK DESCRIPTION (Not URL-s to them). THAT ALLOWS US TO REPRODUCE THE PROBLEM! OTHERWISE WE ARE NOT ABLE TO HELP YOU!
Remember to hide all the security-related pieces of code from the task description, like passwords, server paths etc. for your own safety. Once we close the task, we cannot edit it anymore!
PLEASE PROVIDE THE TEMPLATES AND/OR PHP CODE IN THE TASK DESCRIPTION (Not URL-s to them). THAT ALLOWS US TO REPRODUCE THE PROBLEM! OTHERWISE WE ARE NOT ABLE TO HELP YOU!
Remember to hide all the security-related pieces of code from the task description, like passwords, server paths etc. for your own safety. Once we close the task, we cannot edit it anymore!
FS#178 - Expression token order
Attached to Project:
Open Power Template
Opened by Skruppy (Skrupellos) - Friday, 26 August 2011, 17:13 GMT-8
Opened by Skruppy (Skrupellos) - Friday, 26 August 2011, 17:13 GMT-8
|
DetailsReproduce
========= Create an expression containing a "===" e.g. in an opt:if condition (like in my case) and compile it. ~~~ snip: a.tpl ~~~ <opt:if test="$edit === true"> ~~~ END snip: a.tpl ~~~ Result ====== The compiler struggles interpreting "===" and raises the following exception: ~~~ snip: cli output ~~~ PHP Fatal error: Uncaught exception 'Opt_Expression_Exception' with message 'Invalid token: =' in /Opt/Expression/Standard/Parser.php:2062 Stack trace: #0 /Opt/Expression/Standard/Parser.php(2120): Opt_Expression_Standard_Parser->yy_syntax_error(25, '=') #1 /Opt/Expression/Standard.php(177): Opt_Expression_Standard_Parser->doParse(25, '=') #2 /Opt/Compiler/Class.php(1946): Opt_Expression_Standard->parse('$edit === true', true) #3 /Opt/Instruction/Abstract.php(606): Opt_Compiler_Class->parseExpression('$edit === true', 'parse') #4 /Opt/Instruction/Abstract.php(479): Opt_Instruction_Abstract->_extractAttribute(Object(Opt_Xml_Element), Object(Opt_Xml_Attribute), 6, NULL) #5 /Opt/Instruction/If.php(107): Opt_Instruction_Abstract->_extractAttributes(Object(Opt_Xml_Element), Array) #6 /Opt/Xml/Element.php(503): Opt_Instruction_If->proc in /Opt/Expression/Standard/Parser.php on line 2062 ~~~ END snip: cli output ~~~ adding the following PHP code in Opt/Expression/Standard.php on line 172 (in the while loop) I get the output following afterwards. ~~~ snip: PHP code ~~~ if($expr == '$edit === true') { echo "{$lexer->token} ## {$lexer->value}\n"; } ~~~ END snip: PHP code ~~~ ~~~ snip: debug output ~~~ 57 ## $ 50 ## edit w ## 4 ## == 25 ## = ... The error message ~~~ END snip: debug output ~~~ Assumption ========== I guess the lexer sees the valid "==" token and accepts it before finding an also valid "===". Perhaps this is because of an wrong order in tools/lexer/expression_lexer.plex as shown below: ~~~ snip: expression_lexer.plex ~~~ identifier { switch($this->value) { [...] case 'eq': $this->token = Opt_Expression_Standard_Parser::T_EQUALS; break; case 'neq': $this->token = Opt_Expression_Standard_Parser::T_NEQUALS; case 'eqt': $this->token = Opt_Expression_Standard_Parser::T_EQUALS_T; break; case 'neqt': $this->token = Opt_Expression_Standard_Parser::T_NEQUALS_T; break; ~~~ END snip: expression_lexer.plex ~~~ |
This task depends upon
(Because I've tried to change the order manually and ....)
the snip should show expression_lexer.plex as contained in the official release.
WORKAROUND
==========
According to http://static.invenzzia.org/docs/opt/2_0/book/en/syntax.expressions.operators.html , you can replace "===" with "eqt", "!=" with "neq" and "!==" with "neqt"