list of words or variables separated by spacesvariables start with to use ruleit is translated to an internal form-- dictionary with nested lists to display ruleit is translated back to the string form for instancegiven the callrules internal_rule('rule if ?xb then cd ? 'the conversion in function internal_rule proceeds as followsstring 'rule if ?xb then cd ?xi ['rule '' ?xb then cd ? ' [' ?xb''cd ? ' [''' 'result {'rule':' ''if':[[' ','? '][' ']]'then':[[' '][' ','? ']]we first split around the ifthen around the thenand finally around rule the result is the three substrings that were separated by the keywords test and conclusion substrings are split around ",first and spaces last join is used later to convert back (unparseto the original string for display example - is the concrete implementation of this scheme example - pp \lang\rules py def internal_rule(string) string split(if ' [ split(then ' [ split('rule 'return {'rule' [ strip()'if':internal( [ ])'then':internal( [ ])def external_rule(rule)return ('rule rule['rule'if external(rule['if']then external(rule['then']'def internal(conjunct)res [for clause in conjunct split(',')res append(clause split()return res def external(conjunct)strs [for clause in conjunctstrs append(join(clause)return 'join(strs' bc -[' ' '-[[' ',' '][' ',' '][[' ',' '][' ',' ']-[' '' '-' bc dtoday we could use list comprehensions and generator expressions to gain some conciseness here the internal and external functionsfor instancecould be recoded to simply (see file rules py)def internal(conjunct)return [clause split(for clause in conjunct split(',')string method utilities