module php/pp/main
imports
php/signature/version4
php/signature/version5
php/pp/parenthesize4
php/pp/parenthesize5
php/pp/helpers
php/pp/altsyntax
php/pp/common/main
php/pp/common/operators
php/pp/common/expressions
php/pp/common/statements
php/pp/common/tags
php/pp/version4/statements
php/pp/version5/expressions
php/pp/version5/statements
php/pp/common/literals/main
strategies
// Handle comment annotations
pp-comments(pprules) =
?t{a*}
; where(
<fetch(?(Comment(_), s))> a*
; <pprules> t => b
)
; if !b => V(_, _)
then !V([SOpt(VS(), "0")], [ S(s) | [ b ] ])
|[ V vs=0 [s b] ]|
else
if <explode-string> s => cs@['/', '/' | _]
then <trim(?'\n' + ?'\r' + ?' ' + ?'\t'); implode-string> cs => s1
; !V([SOpt(VS(), "0")], [ S(s1) | [ b ] ])
|[ V vs=0 [s1 b] ]|
else !H([SOpt(HS(), "1")], [ S(s) | [ b ] ])
|[ H hs=1 [s b] ]|
end
end
rules
php-to-box:
None() -> H([SOpt(HS(), "0")], [ S("") ])
box |[ H hs=0 [""] ]|
php-to-box:
Some(c) -> c
php-to-box :
amb(alts) ->
V([SOpt(VS(), "0")], [ V([SOpt(VS(), "0")|[SOpt(IS(), "2")]], [ S("amb>") | [ alts' ] ]) | [ S("<amb") ] ])
V vs=0[V vs=0 is=2 [ "amb>" ~*alts' ] "]
where
<map-with-index({s: \
(i, b) -> H([SOpt(HS(), "1")], [ H([SOpt(HS(), "0")], [ S(s) | [ S(">") ] ]) | [ b ] ])
H hs=1 [ H hs=0 [s ">"] b]
where
<int-to-string> i => s
\})> alts => alts'
signature
constructors
Comment : String -> AnnoKey
amb : List(A) -> A