module php/pp/common/literals/variableLiterals
rules
// Access to arrays and strings as arrays
php-to-box :
ArrayAccess (b1, b2) -> H([SOpt(HS(), "0")], [ b1 | [ S("[") | [ b2 | [ S("]") ] ] ] ])
H hs=0 [ b1 "[" b2 "]"]
// Access to arrays and strings as arrays
php-to-box :
StringAccess (b1, b2) -> H([SOpt(HS(), "0")], [ b1 | [ S("{") | [ b2 | [ S("}") ] ] ] ])
H hs=0 [ b1 "{" b2 "}"]
rules
// Simple and Braced Variables
php-to-box :
Variable(b) -> H([SOpt(HS(), "0")], [ S("$") | [ b ] ])
H hs=0 ["$" b]
php-to-box :
Simple(s) -> H([], [ S(s) ])
H [ s ]
php-to-box :
Braced(b) -> H([SOpt(HS(), "0")], [ S("{") | [ b | [ S("}") ] ] ])
H hs=0 ["{" b "}"]
rules
// Constants
php-to-box :
ConstantVariable(s) -> H([], [ S(s) ])
H [ s ]
rules
// Special variables within objects
php-to-box :
IndirectReference(b) -> H([SOpt(HS(), "0")], [ S("$") | [ b ] ])
H hs=0 ["$" b]
php-to-box :
ObjectAccess(b1,b2) -> H([SOpt(HS(), "0")], [ b1 | [ S("->") | [ b2 ] ] ])
H hs=0 [ b1 "->" b2 ]
php-to-box :
ObjectProperty(b) -> b
php-to-box :
FunctionCall(var,function,exprs) -> H([SOpt(HS(), "0")], [ var | [ S("->") | [ function | [ args ] ] ] ])
box |[ H hs= 0 [~var "->" ~function ~args] ]|
where <list-to-args> exprs => args
rules
// Special bool, null
php-to-box :
True() -> H([], [ S("true") ])
H [ "true" ]
php-to-box :
False() -> H([], [ S("false") ])
H [ "false" ]
php-to-box :
Null() -> H([], [ S("null") ])
H [ "null" ]