Closed huynhminhson closed 10 years ago
Hey @huynhminhson, can you write for use an example, and how it will be compiled?? and we will work on it and tnx :)
Hi, below is the code and its error for your reference :) I expected it will be compiled to
Mage::app()->getId()
{{ Mage::app().getId() }}
{ [SyntaxError: Expected "!", "!=", "!==", "%", "%=", "&", "&&", "&=", "(", "*", "*=", "+", "++", "+=", ",", "-", "--", "-=", "->", ".", ".=", "/", "/*", "//", "/=", "<", "<<", "<<=", "<=", "=", "==", "===", ">", ">=", ">>", ">>=", ">>>", ">>>=", "?", "NULL", "None", "[", "\\", "\n", "\r", "\r\n", "^", "^=", "`", "and", "class", "false", "for", "if", "namespace", "new", "of", "or", "switch", "this", "true", "try", "while", "|", "|=", "||", "}}", "~", [ \t], comment, identifier, number, string or whitespace but ":" found.] name: 'SyntaxError', expected: [ '"!"', '"!="', '"!=="', '"%"', '"%="', '"&"', '"&&"', '"&="', '"("', '"*"', '"*="', '"+"', '"++"', '"+="', '","', '"-"', '"--"', '"-="', '"->"', '"."', '".="', '"/"', '"/*"', '"//"', '"/="', '"<"', '"<<"', '"<<="', '"<="', '"="', '"=="', '"==="', '">"', '">="', '">>"', '">>="', '">>>"', '">>>="', '"?"', '"NULL"', '"None"', '"["', '"\\\\"', '"\\n"', '"\\r"', '"\\r\\n"', '"^"', '"^="', '"`"', '"and"', '"class"', '"false"', '"for"', '"if"', '"namespace"', '"new"', '"of"', '"or"', '"switch"', '"this"', '"true"', '"try"', '"while"', '"|"', '"|="', '"||"', '"}}"', '"~"', '[ \\t]', 'comment', 'identifier', 'number', 'string', 'whitespace' ], found: ':', message: 'Expected "!", "!=", "!==", "%", "%=", "&", "&&", "&=", "(", "*", "*=", "+", "++", "+=", ",", "-", "--", "-=", "->", ".", ".=", "/", "/*", "//", "/=", "<", "<<", "<<=", "<=", "=", "==", "===", ">", ">=", ">>", ">>=", ">>>", ">>>=", "?", "NULL", "None", "[", "\\\\", "\\n", "\\r", "\\r\\n", "^", "^=", "`", "and", "class", "false", "for", "if", "namespace", "new", "of", "or", "switch", "this", "true", "try", "while", "|", "|=", "||", "}}", "~", [ \\t], comment, identifier, number, string or whitespace but ":" found.', offset: 8, line: 2, column: 5 }
For this time, Mammouth don't support Scope Resolution Operator,
I'm now studying PHP Scope Resolution Operator, and trying to find a quick equivalent for this feature.
in Mammouth, m.s
is compiled to $m->s
.
If you have any suggestions, you're welcome.
Hey, @huynhminhson, see this now: http://mammouth.wamalaka.com/#try:{{%0AMage%3A%3Aapp%28%29.getId%28%29%0A}} this feature is available since v0.2.2, update mammouth now via npm or download the Github Repo. tnx again
Thanks for for your quick reply and action. However there is another small issue.
{{ Mage::app().getId() }}is now compiled to
$Mage::app()->getId()but it should be
Mage::app()->getId()
(without $, Mage is a class, not a variable)
@huynhminhson, I have only one question to fix this, are Mage, in your example can be a variable like this?? in PHP
$Mage = new Class()
$Mage::app()->getId()
or
$Mage = new Class()
Mage::app()->getId()
I'm not good in PHP :(
Mage is a predefined class, Mage::app() is to call method app() in class Mage.
class Mage { public function app() { ...}}
The right syntax is
Mage::app()->getId()
I had found this example in php documentation:
class MyClass
{
const CONSTANT = 'constant value';
function showConstant() {
echo self::CONSTANT . "\n";
}
}
echo MyClass::CONSTANT . "\n";
$classname = "MyClass";
echo $classname::CONSTANT . "\n"; // As of PHP 5.3.0
$class = new MyClass();
$class->showConstant();
echo $class::CONSTANT."\n";
I think that Mammouth compiler should be written from zero, because the current compiler can't do a difference between classes and variables.
I met an issue with Scope Resolution Operator (::), mammouth cannot parse it.