module languages/php/common/literals/doubleQuotedStringLiterals

rules
// The main printer for strings
  php-to-box :
    DoubleQuoted(parts) -> H([SOpt(HS(), "0")], [ S("\"") | [ str | [ S("\"") ] ] ])
H hs=0 [ "\"" ~str "\"" ]
where <lit-of-esc-to-string> parts => str rules // Hexachars esc-to-string : HexaChar(b1) -> H([SOpt(HS(), "0")], [ S("\\x") | [ b1' ] ])
H hs=0 [ "\\x" ~b1' ]
where <asc-to-norm> b1 => b1' esc-to-string : HexaChar(b1,b2) -> H([SOpt(HS(), "0")], [ S("\\x") | [ b1' | [ b2' ] ] ])
H hs=0 [ "\\x" ~b1' ~b2' ]
where <asc-to-norm> b1 => b1' ; <asc-to-norm> b2 => b2' // Octachars esc-to-string : OctaChar(b1) -> H([SOpt(HS(), "0")], [ S("\\") | [ b1' ] ])
H hs=0 [ "\\" ~b1' ]
where <asc-to-norm> b1 => b1' esc-to-string : OctaChar(b1,b2) -> H([SOpt(HS(), "0")], [ S("\\") | [ b1' | [ b2' ] ] ])
H hs = 0 [ "\\" ~b1' ~b2' ]
where <asc-to-norm> b1 => b1' ; <asc-to-norm> b2 => b2' esc-to-string : OctaChar(b1,b2,b3) -> H([SOpt(HS(), "0")], [ S("\\") | [ b1' | [ b2' | [ b3' ] ] ] ])
H hs = 0 [ "\\" ~b1' ~b2' ~b3' ]
where <asc-to-norm> b1 => b1' ; <asc-to-norm> b2 => b2' ; <asc-to-norm> b3 => b3' // Normal escape variable, simple syntax esc-to-string : VariableBraced(s) -> H([], [ S("${") | [ S(s) | [ S("}") ] ] ])
H [ "${" s "}" ]
esc-to-string : Variable(b) -> H([SOpt(HS(), "0")], [ S("$") | [ b' ] ])
H hs=0 [ "$" ~b' ]
where <php-to-box> b => b' esc-to-string : ArrayAccess(b,s) -> H([SOpt(HS(), "0")], [ b' | [ S("[") | [ S(s) | [ S("]") ] ] ] ])
|[ H hs=0 [ ~b' "[" s "]"] ]|
where <esc-to-string> b => b' ; <is-string> s esc-to-string : BracedArrayAccess(b,s) -> H([SOpt(HS(), "0")], [ b' | [ S("[") | [ S(s) | [ S("]") | [ S("}") ] ] ] ] ])
|[ H hs=0 [ ~b' "[" s "]" "}" ] ]|
where <esc-to-string> b => b' ; <is-string> s esc-to-string : ArrayAccess(b,e) -> H([SOpt(HS(), "0")], [ b' | [ S("[") | [ e' | [ S("]") ] ] ] ])
|[ H hs=0 [ ~b' "[" ~e' "]"] ]|
where <esc-to-string> b => b' ; <not(is-string)> e ; e' := <php-to-box> e esc-to-string : BracedArrayAccess(b,e) -> H([SOpt(HS(), "0")], [ b' | [ S("[") | [ e' | [ S("]") | [ S("}") ] ] ] ] ])
|[ H hs=0 [ ~b' "[" ~e' "]" "}" ] ]|
where <esc-to-string> b => b' ; <not(is-string)> e ; e' := <php-to-box <+ esc-to-string> e esc-to-string : EmbeddedArrayVariable(s) -> H([SOpt(HS(), "0")], [ S("${") | [ S(s) ] ])
|[ H hs=0 ["${" s ] ]|
esc-to-string : EmbeddedString(s) -> H([SOpt(HS(), "0")], [ S("'") | [ S(s) | [ S("'") ] ] ])
|[ H hs=0 [ "'" s "'" ] ]|
esc-to-string : ObjectAccess(b,s) -> H([SOpt(HS(), "0")], [ b' | [ S("->") | [ S(s) ] ] ])
|[ H hs=0 [ ~b' "->" s ] ]|
where <esc-to-string> b => b'