#!/usr/bin/python import treemeta s = r""" class rule[treemeta.lib] : GOAL = TEXT * # define function GOAL TEXT = .LABEL $( ', .LABEL :DO[2] ) DO [-,-] => *1 *2 """ c = treemeta.compile(s) # compile rule set exec c # create rule class r = rule() # create rule instance i = 'first, second, third' o = r.GOAL(i) # call function from class
class rule[treemeta.lib] : # define rule as class with TreeMeta GOAL = TEXT * TEXT = .SR $( ', .SR :DO[2] ) DO [-,-] => *1 *2 r = rule() # create rule instance i = 'first, second, third' o = r.GOAL(i) # call function from class
#!/usr/bin/dython # global rule(s) def'd inline
#!/usr/bin/dython [ GOAL = TEXT * # TreeMeta specification bewteen []'s TEXT = .LABEL $( ', .LABEL :DO[2] ) # to create function GOAL() DO [-,-] => *1 *2 ] i = 'first, second, third' o = GOAL(i) # rule based processing function call