module php/pp/common/statements

rules
// Simple expression
  php-to-box:
    Expr(e) -> H([SOpt(HS(), "0")], [ e | [ S(";") ] ])
H hs=0 [ ~e ";" ]
php-to-box: Expr(e,_) -> H([SOpt(HS(), "0")], [ e ])
H hs=0 [ ~e ]
rules // Block statement php-to-box: Block(stats) ->
V([SOpt(VS(), "0")], [ V([SOpt(VS(), "0")|[SOpt(IS(), "2")]], [ H([SOpt(HS(), "0")], [ S("{") ]) | [ stats ] ]) | [ H([SOpt(HS(), "0")], [ S("}") ]) ] ])
V vs=0 [ V vs=0 is=2 [ H hs=0 [ "{" ] ~*stats ] H hs=0 [ "}"] ]
rules // If, somewhat involved with all the three different constructors php-to-box: If(cond,Block(stat)) ->
V([SOpt(VS(), "0")], [ V([SOpt(VS(), "0")|[SOpt(IS(), "2")]], [ H([SOpt(HS(), "1")], [ FBOX(KW(), S("if")) | [ H([SOpt(HS(), "0")], [ S("(") | [ cond | [ S(")") | [ S("{") ] ] ] ]) ] ]) | [ stat ] ]) | [ H([SOpt(HS(), "0")], [ S("}") ]) ] ])
V vs=0 [ V vs=0 is=2 [ H hs=1 [ KW["if"] H hs=0 ["(" ~cond ")" "{" ] ] ~*stat ] H hs=0 [ "}" ] ]
php-to-box: If(cond,stat) ->
V([SOpt(VS(), "0")|[SOpt(IS(), "2")]], [ H([SOpt(HS(), "1")], [ FBOX(KW(), S("if")) | [ H([SOpt(HS(), "0")], [ S("(") | [ cond | [ S(")") ] ] ]) ] ]) | [ stat ] ])
V vs=0 is=2 [ H hs=1 [ KW["if"] H hs=0 ["(" ~cond ")" ] ] ~stat ]
where not (!stat => Block(_)) php-to-box: If(cond,Block(stat),elseif) ->
V([SOpt(VS(), "0")], [ V([SOpt(VS(), "0")|[SOpt(IS(), "2")]], [ H([SOpt(HS(), "1")], [ FBOX(KW(), S("if")) | [ H([SOpt(HS(), "0")], [ S("(") | [ cond | [ S(")") | [ S("{") ] ] ] ]) ] ]) | [ stat ] ]) | [ H([SOpt(HS(), "1")], [ S("}") | [ elseif ] ]) ] ])
V vs=0 [ V vs=0 is=2 [ H hs=1 [ KW["if"] H hs=0 ["(" ~cond ")" "{" ] ] ~*stat ] H hs=1 [ "}" ~*elseif ] ]
php-to-box: If(cond,stat,elseif) ->
V([SOpt(VS(), "0")], [ V([SOpt(VS(), "0")|[SOpt(IS(), "2")]], [ H([SOpt(HS(), "1")], [ FBOX(KW(), S("if")) | [ H([SOpt(HS(), "0")], [ S("(") | [ cond | [ S(")") ] ] ]) ] ]) | [ stat ] ]) | [ elseif ] ])
V vs=0 [ V vs=0 is=2 [ H hs=1 [ KW["if"] H hs=0 ["(" ~cond ")" ] ] ~stat ] ~*elseif ]
where not (!stat => Block(_)) ;not (!elseif => []) php-to-box: If(cond,stat,[],els) ->
V([SOpt(VS(), "0")], [ V([SOpt(VS(), "0")|[SOpt(IS(), "2")]], [ H([SOpt(HS(), "1")], [ FBOX(KW(), S("if")) | [ H([SOpt(HS(), "0")], [ S("(") | [ cond | [ S(")") ] ] ]) ] ]) | [ stat ] ]) | [ V([SOpt(VS(), "0")|[SOpt(IS(), "2")]], [ H([SOpt(HS(), "1")], [ FBOX(KW(), S("else")) ]) | [ els ] ]) ] ])
V vs=0 [ V vs=0 is=2 [ H hs=1 [ KW["if"] H hs=0 ["(" ~cond ")"] ] ~stat ] V vs=0 is=2 [ H hs=1 [ KW["else"] ] ~els ] ]
where not (!els => Block(_)) ; not (!stat => Block(_)) php-to-box: If(cond,stat,[],Block(els)) ->
V([SOpt(VS(), "0")], [ V([SOpt(VS(), "0")|[SOpt(IS(), "2")]], [ H([SOpt(HS(), "1")], [ FBOX(KW(), S("if")) | [ H([SOpt(HS(), "0")], [ S("(") | [ cond | [ S(")") ] ] ]) ] ]) | [ stat ] ]) | [ V([SOpt(VS(), "0")|[SOpt(IS(), "2")]], [ H([SOpt(HS(), "0")], [ FBOX(KW(), S("else")) | [ S("{") ] ]) | [ els ] ]) | [ H([SOpt(HS(), "0")], [ S("}") ]) ] ] ])
V vs=0 [ V vs=0 is=2 [ H hs=1 [ KW["if"] H hs=0 ["(" ~cond ")"] ] ~stat ] V vs=0 is=2 [ H hs=0 [ KW["else"] "{" ] ~*els ] H hs=0 [ "}" ] ]
where not (!stat => Block(_)) php-to-box: If(cond,Block(stat),[],els) ->
V([SOpt(VS(), "0")], [ V([SOpt(VS(), "0")|[SOpt(IS(), "2")]], [ H([SOpt(HS(), "1")], [ FBOX(KW(), S("if")) | [ H([SOpt(HS(), "0")], [ S("(") | [ cond | [ S(")") | [ S("{") ] ] ] ]) ] ]) | [ stat ] ]) | [ V([SOpt(VS(), "0")|[SOpt(IS(), "2")]], [ H([SOpt(HS(), "1")], [ S("}") | [ FBOX(KW(), S("else")) ] ]) | [ els ] ]) ] ])
V vs=0 [ V vs=0 is=2 [ H hs=1 [ KW["if"] H hs=0 ["(" ~cond ")" "{"] ] ~*stat ] V vs=0 is=2 [ H hs=1 [ "}" KW["else"] ] ~els ] ]
where not (!els => Block(_)) php-to-box: If(cond,Block(stat),[],Block(els)) ->
V([SOpt(VS(), "0")], [ V([SOpt(VS(), "0")|[SOpt(IS(), "2")]], [ H([SOpt(HS(), "1")], [ FBOX(KW(), S("if")) | [ H([SOpt(HS(), "0")], [ S("(") | [ cond | [ S(")") | [ S("{") ] ] ] ]) ] ]) | [ stat ] ]) | [ V([SOpt(VS(), "0")|[SOpt(IS(), "2")]], [ H([SOpt(HS(), "1")], [ S("}") | [ H([SOpt(HS(), "0")], [ FBOX(KW(), S("else")) | [ S("{") ] ]) ] ]) | [ els ] ]) | [ H([SOpt(HS(), "0")], [ S("}") ]) ] ] ])
V vs=0 [ V vs=0 is=2 [ H hs=1 [ KW["if"] H hs=0 ["(" ~cond ")" "{"] ] ~*stat ] V vs=0 is=2 [ H hs=1 [ "}" H hs=0 [KW["else"] "{" ]] ~*els ] H hs=0 [ "}" ] ]
php-to-box: If(cond,stat,elseif,els) ->
V([SOpt(VS(), "0")], [ V([SOpt(VS(), "0")|[SOpt(IS(), "2")]], [ H([SOpt(HS(), "1")], [ FBOX(KW(), S("if")) | [ H([SOpt(HS(), "0")], [ S("(") | [ cond | [ S(")") ] ] ]) ] ]) | [ stat ] ]) | [ elseif | [ els' ] ] ])
V vs=0 [ V vs=0 is=2 [ H hs=1 [ KW["if"] H hs=0 ["(" ~cond ")"] ] ~stat ] ~*elseif ~els' ]
where els' := <else-to-box> els ; not (!stat => Block(_)) php-to-box: If(cond,Block(stat),elseif,els) ->
V([SOpt(VS(), "0")], [ V([SOpt(VS(), "0")|[SOpt(IS(), "2")]], [ H([SOpt(HS(), "1")], [ FBOX(KW(), S("if")) | [ H([SOpt(HS(), "0")], [ S("(") | [ cond | [ S(")") | [ S("{") ] ] ] ]) ] ]) | [ stat ] ]) | [ H([SOpt(HS(), "1")], [ S("}") ]) | [ elseif | [ els' ] ] ] ])
V vs=0 [ V vs=0 is=2 [ H hs=1 [ KW["if"] H hs=0 ["(" ~cond ")" "{"] ] ~*stat ] H hs=1 [ "}" ] ~*elseif ~els' ]
where els' := <else-to-box> els ;not (!elseif => []) else-to-box: Block(stat) ->
V([SOpt(VS(), "0")], [ V([SOpt(VS(), "0")|[SOpt(IS(), "2")]], [ H([SOpt(HS(), "0")], [ FBOX(KW(), S("else")) | [ S("{") ] ]) | [ stat ] ]) | [ H([SOpt(HS(), "0")], [ S("}") ]) ] ])
V vs=0 [ V vs=0 is=2 [ H hs=0 [ KW["else"] "{"] ~*stat ] H hs=0 [ "}" ] ]
else-to-box: stat ->
V([SOpt(VS(), "0")|[SOpt(IS(), "2")]], [ H([SOpt(HS(), "0")], [ FBOX(KW(), S("else")) ]) | [ stat ] ])
V vs=0 is=2 [ H hs=0 [ KW["else"] ] ~stat ]
where not (!stat => Block(_)) php-to-box: ElseIf(cond,Block(stat)) ->
V([SOpt(VS(), "0")], [ V([SOpt(VS(), "0")|[SOpt(IS(), "2")]], [ H([SOpt(HS(), "1")], [ FBOX(KW(), S("elseif")) | [ H([SOpt(HS(), "0")], [ S("(") | [ cond | [ S(")") | [ S("{") ] ] ] ]) ] ]) | [ stat ] ]) | [ H([SOpt(HS(), "0")], [ S("}") ]) ] ])
V vs=0 [ V vs=0 is=2 [ H hs=1 [KW["elseif"] H hs=0 ["(" ~cond ")" "{"]] ~*stat ] H hs=0 [ "}" ] ]
php-to-box: ElseIf(cond,stat) ->
V([SOpt(VS(), "0")|[SOpt(IS(), "2")]], [ H([SOpt(HS(), "1")], [ FBOX(KW(), S("elseif")) | [ H([SOpt(HS(), "0")], [ S("(") | [ cond | [ S(")") ] ] ]) ] ]) | [ stat ] ])
V vs=0 is=2 [ H hs=1 [KW["elseif"] H hs=0 ["(" ~cond ")" ]] ~stat ]
where not (!stat => Block(_)) rules // While statements php-to-box: While(cond,stat) ->
V([SOpt(VS(), "0")|[SOpt(IS(), "2")]], [ H([SOpt(HS(), "1")], [ FBOX(KW(), S("while")) | [ H([SOpt(HS(), "0")], [ S("(") | [ cond | [ S(")") ] ] ]) ] ]) | [ stat ] ])
V vs=0 is=2 [ H hs=1 [ KW["while"] H hs=0 ["(" ~cond ")"] ] ~stat ]
where not(!stat => Block(_)) php-to-box: While(cond,Block(stats)) ->
V([SOpt(VS(), "0")], [ V([SOpt(VS(), "0")|[SOpt(IS(), "2")]], [ H([SOpt(HS(), "1")], [ FBOX(KW(), S("while")) | [ H([SOpt(HS(), "0")], [ S("(") | [ cond | [ S(")") | [ S("{") ] ] ] ]) ] ]) | [ stats ] ]) | [ H([SOpt(HS(), "0")], [ S("}") ]) ] ])
V vs=0 [ V vs=0 is=2 [ H hs=1 [ KW["while"] H hs=0 ["(" ~cond ")" "{"] ] ~*stats ] H hs=0 ["}"] ]
php-to-box: DoWhile(stat,cond) ->
V([SOpt(IS(), "2")|[SOpt(VS(), "0")]], [ FBOX(KW(), S("do")) | [ stat | [ H([SOpt(HS(), "0")], [ FBOX(KW(), S("while")) | [ S("(") | [ cond | [ S(")") | [ S(";") ] ] ] ] ]) ] ] ])
V is=2 vs=0 [KW["do"] ~stat H hs=0 [KW["while"] "(" ~cond ")" ";"]]
where not(!stat => Block(_)) php-to-box: DoWhile(Block(stat),cond) ->
V([SOpt(VS(), "0")], [ V([SOpt(VS(), "0")|[SOpt(IS(), "2")]], [ H([SOpt(HS(), "0")], [ FBOX(KW(), S("do")) | [ S("{") ] ]) | [ stat ] ]) | [ H([SOpt(HS(), "1")], [ S("}") | [ FBOX(KW(), S("while")) | [ H([SOpt(HS(), "0")], [ S("(") | [ cond | [ S(")") | [ S(";") ] ] ] ]) ] ] ]) ] ])
V vs=0 [ V vs=0 is=2 [ H hs=0 [ KW["do"] "{" ] ~*stat ] H hs=1 [ "}" KW["while"] H hs=0 ["(" ~cond ")" ";"]] ]
rules // For statement php-to-box: For(init,cond,update,stat) ->
V([SOpt(IS(), "2")|[SOpt(VS(), "0")]], [ H([SOpt(HS(), "1")], [ FBOX(KW(), S("for")) | [ H([SOpt(HS(), "0")], [ S("(") | [ init' | [ H([SOpt(HS(), "1")], [ S(";") | [ cond' ] ]) | [ H([SOpt(HS(), "1")], [ S(";") | [ update' ] ]) | [ S(")") ] ] ] ] ]) ] ]) | [ stat ] ])
V is=2 vs=0 [ H hs=1 [ KW["for"] H hs=0 ["(" ~init' H hs=1 [";" ~cond'] H hs=1 [";" ~update'] ")" ]] ~stat ]
where not(!stat => Block(_)) ;<separate-by-comma> init => init' ;<separate-by-comma> cond => cond' ;<separate-by-comma> update => update' php-to-box: For(init,cond,update,Block(stat)) ->
V([SOpt(VS(), "0")], [ V([SOpt(VS(), "0")|[SOpt(IS(), "2")]], [ H([SOpt(HS(), "1")], [ FBOX(KW(), S("for")) | [ H([SOpt(HS(), "0")], [ S("(") | [ init' | [ H([SOpt(HS(), "1")], [ S(";") | [ cond' ] ]) | [ H([SOpt(HS(), "1")], [ S(";") | [ update' ] ]) | [ S(")") | [ S("{") ] ] ] ] ] ]) ] ]) | [ stat ] ]) | [ H([SOpt(HS(), "0")], [ S("}") ]) ] ])
V vs=0 [ V vs=0 is=2 [ H hs=1 [ KW["for"] H hs=0 ["(" ~init' H hs=1 [";" ~cond'] H hs=1 [";" ~update'] ")" "{" ]] ~*stat ] H hs=0 [ "}" ] ]
where <separate-by-comma> init => init' ;<separate-by-comma> cond => cond' ;<separate-by-comma> update => update' rules // Switch statement php-to-box: Switch(sub,cases) ->
V([SOpt(VS(), "0")], [ V([SOpt(VS(), "0")|[SOpt(IS(), "2")]], [ H([SOpt(HS(), "1")], [ FBOX(KW(), S("switch")) | [ H([SOpt(HS(), "0")], [ S("(") | [ sub | [ S(")") | [ S("{") ] ] ] ]) ] ]) | [ cases ] ]) | [ H([SOpt(HS(), "0")], [ S("}") ]) ] ])
V vs=0 [ V vs=0 is=2 [ H hs=1 [KW["switch"] H hs=0 ["(" ~sub ")" "{"]] ~*cases ] H hs=0 ["}"] ]
php-to-box: Case(expr,_,topstat) ->
V([SOpt(VS(), "0")|[SOpt(IS(), "2")]], [ H([SOpt(HS(), "1")], [ FBOX(KW(), S("case")) | [ H([SOpt(HS(), "0")], [ expr | [ S(":") ] ]) ] ]) | [ topstat ] ])
V vs=0 is=2 [H hs=1 [ KW["case"] H hs=0 [~expr ":"] ] ~*topstat ]
php-to-box: DefaultCase(_,topstat) ->
V([SOpt(VS(), "0")|[SOpt(IS(), "2")]], [ H([SOpt(HS(), "0")], [ FBOX(KW(), S("default")) | [ S(":") ] ]) | [ topstat ] ])
V vs=0 is=2 [H hs=0 [KW["default"] ":" ] ~*topstat ]
rules // break, continue and return statements php-to-box: Break(expr) ->
H([SOpt(HS(), "0")], [ H([SOpt(HS(), "1")], [ FBOX(KW(), S("break")) | [ expr ] ]) | [ S(";") ] ])
H hs=0 [H hs=1 [KW["break"] ~expr] ";"]
where <not(eq)> (expr,None()) php-to-box: Break(None()) -> H([SOpt(HS(), "0")], [ FBOX(KW(), S("break")) | [ S(";") ] ])
H hs=0 [KW["break"] ";"]
php-to-box: Continue(expr) ->
H([SOpt(HS(), "0")], [ H([SOpt(HS(), "1")], [ FBOX(KW(), S("continue")) | [ expr ] ]) | [ S(";") ] ])
H hs=0 [H hs=1 [KW["continue"] ~expr] ";"]
where <not(eq)> (expr,None()) php-to-box: Continue(None()) -> H([SOpt(HS(), "0")], [ FBOX(KW(), S("continue")) | [ S(";") ] ])
H hs=0 [KW["continue"] ";"]
php-to-box: Return(expr) ->
H([SOpt(HS(), "0")], [ H([SOpt(HS(), "1")], [ FBOX(KW(), S("return")) | [ expr ] ]) | [ S(";") ] ])
H hs=0 [H hs=1 [KW["return"] ~expr] ";"]
where <not(eq)> (expr,None()) php-to-box: Return(None()) -> H([SOpt(HS(), "0")], [ FBOX(KW(), S("return")) | [ S(";") ] ])
H hs=0 [KW["return"] ";"]
rules // Global variable statements php-to-box: DeclareGlobal(vars) ->
H([SOpt(HS(), "0")], [ H([SOpt(HS(), "1")], [ FBOX(KW(), S("global")) | [ vars' ] ]) | [ S(";") ] ])
H hs=0 [ H hs=1 [ KW["global"] ~vars' ] ";"]
where <separate-by-comma> vars => vars' rules // Static variable statements php-to-box: DeclareStatic(vars) ->
H([SOpt(HS(), "0")], [ H([SOpt(HS(), "1")], [ FBOX(KW(), S("static")) | [ vars' ] ]) | [ S(";") ] ])
H hs=0 [ H hs=1 [ KW["static"] ~vars' ] ";"]
where <separate-by-comma> vars => vars' php-to-box: StaticVariable(var) -> var php-to-box: StaticVariable(var,val) -> H([SOpt(HS(), "1")], [ var | [ S("=") | [ val ] ] ])
H hs=1 [ ~var "=" ~val ]
rules // Unset variable statements php-to-box: Unset(vars) ->
H([SOpt(HS(), "0")], [ H([SOpt(HS(), "0")], [ FBOX(KW(), S("unset")) | [ S("(") | [ vars' | [ S(")") ] ] ] ]) | [ S(";") ] ])
H hs=0 [ H hs=0 [ KW["unset"] "(" ~vars' ")" ] ";"]
where <separate-by-comma> vars => vars' rules // Echo statement php-to-box: Echo(exprs,"") -> H([SOpt(HS(), "1")], [ FBOX(KW(), S("echo")) | [ args ] ])
H hs=1 [ KW["echo"] ~args ]
where <separate-by-comma> exprs => args php-to-box: Echo(exprs) ->
H([SOpt(HS(), "1")], [ FBOX(KW(), S("echo")) | [ H([SOpt(HS(), "0")], [ args | [ S(";") ] ]) ] ])
H hs=1 [ KW["echo"] H hs=0 [ ~args ";"] ]
where <separate-by-comma> exprs => args rules // HTML php-to-box: InlineHTML(close,litorechos,open) -> H([SOpt(HS(), "0")], [ close | [ litorechos' | [ open ] ] ])
H hs=0 [ ~close ~litorechos' ~open ]
where <lit-or-echo> litorechos => litorechos' php-to-box: InlineEcho(echoopen,expr,_,close) ->
H([SOpt(HS(), "1")], [ echoopen | [ H([SOpt(HS(), "0")], [ expr | [ S(";") ] ]) | [ close ] ] ])
H hs=1 [ ~echoopen H hs=0 [ ~expr ";"] ~close ]
rules // Foreach statement php-to-box: ForEach(var,pattern,stat) ->
V([SOpt(IS(), "2")|[SOpt(VS(), "0")]], [ H([SOpt(HS(), "1")], [ FBOX(KW(), S("foreach")) | [ H([SOpt(HS(), "0")], [ S("(") | [ H([SOpt(HS(), "1")], [ var | [ S("as") | [ pattern ] ] ]) | [ S(")") ] ] ]) ] ]) | [ stat ] ])
V is=2 vs=0 [H hs=1 [KW["foreach"] H hs=0 ["(" H hs=1 [ ~var "as" ~pattern ] ")"] ] ~stat]
where not(!stat => Block(_)) php-to-box: ForEach(var,pattern,Block(stat)) ->
V([SOpt(VS(), "0")], [ V([SOpt(VS(), "0")|[SOpt(IS(), "2")]], [ H([SOpt(HS(), "1")], [ FBOX(KW(), S("foreach")) | [ H([SOpt(HS(), "0")], [ S("(") | [ H([SOpt(HS(), "1")], [ var | [ S("as") | [ pattern ] ] ]) | [ S(")") | [ S("{") ] ] ] ]) ] ]) | [ stat ] ]) | [ H([SOpt(HS(), "0")], [ S("}") ]) ] ])
V vs=0 [ V vs=0 is=2 [ H hs=1 [KW["foreach"] H hs=0 ["(" H hs=1 [ ~var "as" ~pattern ] ")" "{"]] ~*stat ] H hs=0 ["}"] ]
php-to-box: Pattern(key,val) -> H([SOpt(HS(), "0")], [ key | [ val ] ])
H hs=0 [ ~key ~val ]
php-to-box: Key(var) -> H([SOpt(HS(), "1")], [ var | [ S("=>") ] ])
H hs=1 [ ~var "=>" ]
rules // Empty statement php-to-box: Empty() -> H([SOpt(HS(), "0")], [ S(";") ])
H hs=0 [ ";" ]
rules // Declare statement php-to-box: Declare(decls,stat) ->
V([SOpt(IS(), "2")|[SOpt(VS(), "0")]], [ H([SOpt(HS(), "0")], [ FBOX(KW(), S("declare")) | [ S("(") | [ decls | [ S(")") ] ] ] ]) | [ stat ] ])
V is=2 vs=0 [H hs=0 [KW["declare"] "(" ~*decls ")"] ~stat]
where not(!stat => Block(_)) php-to-box: Declare(decls,Block(stats)) ->
V([SOpt(VS(), "0")], [ V([SOpt(VS(), "0")|[SOpt(IS(), "2")]], [ H([SOpt(HS(), "0")], [ FBOX(KW(), S("declare")) | [ S("(") | [ decls | [ S(")") | [ S("{") ] ] ] ] ]) | [ stats ] ]) | [ H([SOpt(HS(), "0")], [ S("}") ]) ] ])
V vs=0 [ V vs=0 is=2 [ H hs=0 [KW["declare"] "(" ~*decls ")" "{" ] ~*stats ] H hs=0 ["}"] ]
php-to-box: Directive(s,val) -> H([SOpt(HS(), "1")], [ S(s) | [ S("=") | [ val ] ] ])
H hs=1 [ s "=" ~val ]
rules // Function decleration statement php-to-box: FunctionDecl(s,params,topstat) ->
V([SOpt(VS(), "0")], [ V([SOpt(VS(), "0")|[SOpt(IS(), "2")]], [ H([SOpt(HS(), "1")], [ FBOX(KW(), S("function")) | [ H([SOpt(HS(), "0")], [ S(s) | [ S("(") | [ params' | [ S(")") | [ S("{") ] ] ] ] ]) ] ]) | [ topstat ] ]) | [ H([SOpt(HS(), "0")], [ S("}") ]) ] ])
V vs=0 [ V vs=0 is=2 [ H hs=1 [ KW["function"] H hs=0 [ s "(" ~params' ")" "{"]] ~*topstat ] H hs=0 ["}"] ]
where <separate-by-comma> params => params' php-to-box: FunctionDeclRef(s,params,topstat) ->
V([SOpt(VS(), "0")], [ V([SOpt(VS(), "0")|[SOpt(IS(), "2")]], [ H([SOpt(HS(), "1")], [ FBOX(KW(), S("function")) | [ H([SOpt(HS(), "0")], [ S("&") | [ S(s) | [ S("(") | [ params' | [ S(")") | [ S("{") ] ] ] ] ] ]) ] ]) | [ topstat ] ]) | [ H([SOpt(HS(), "0")], [ S("}") ]) ] ])
V vs=0 [ V vs=0 is=2 [ H hs=1 [ KW["function"] H hs=0 [ "&" s "(" ~params' ")" "{"]] ~*topstat ] H hs=0 ["}"] ]
where <separate-by-comma> params => params' php-to-box: Param(var) -> var php-to-box: ParamRef(var) -> H([SOpt(HS(), "0")], [ S("&") | [ var ] ])
H hs=0 [ "&" ~var]
php-to-box: ParamConstant(var) -> H([SOpt(HS(), "1")], [ S("const") | [ var ] ])
H hs=1 [ "const" ~var]
php-to-box: ParamDefault(var,val) -> H([SOpt(HS(), "1")], [ var | [ S("=") | [ val ] ] ])
H hs=1 [ ~var "=" ~val ]
rules // Class decleration statement for both 4 and 5 php-to-box: Extends(s) -> H([SOpt(HS(), "1")], [ FBOX(KW(), S("extends")) | [ S(s) ] ])
H hs=1 [ KW["extends"] s ]
php-to-box: Normal() -> H([], [ FBOX(KW(), S("class")) ])
H [ KW["class"] ]
php-to-box: Normal(var) -> var php-to-box: Default(var,val) -> H([SOpt(HS(), "1")], [ var | [ S("=") | [ val ] ] ])
H hs=1 [ ~var "=" ~val ]
php-to-box: InstanceVariable(vars) ->
H([SOpt(HS(), "1")], [ S("var") | [ H([SOpt(HS(), "0")], [ vars' | [ S(";") ] ]) ] ])
H hs=1 [ "var" H hs=0 [~vars' ";" ]]
where <separate-by-comma> vars => vars'