Let’s make a simple one that just tries to match
the input as a PHP program:

% Main rule to match PHP programs
function main
replace program
PHPprogram program
construct Message id
_ message “matched it!”
by
PHPprogram
end function

The
program doesn’t really do anything other than
match an input PHP program and transform it to
its parsed self,
exactly once (because this main rule is a TXL
function, not a rule).

Support
Having trouble with Txl,
NiCad, or Turing+?
Ask a question, report a bug or difficulty in the
Txl Forum. The
target type of this rule must be a class declaration,
which according to the PHP grammar is defined as:

define ClassDecl
ClassType id NL
ExtendsClause?
ImplementsClause?
‘{ NLIN
ClassMember* EX
‘} NL
end define
try here

So the rule we
have Check Out Your URL mind should look something like this:

rule publicAfterPrivate
replace $ ClassDecl
ClassType ClassType ClassName id
Extends ExtendsClause?
Implements ImplementsClause?
‘{
ClassMembers ClassMember*
‘}
by
ClassType ClassName
Extends
Implements
‘{
ClassMembers
‘}
end rule

Make this rule,
save the program, and run it on the PHP example
ApiBase. .