!7 cprint { start-thread { S riddle = "STATIC ALA FLATTEN LIST OF PAIRS L PAIR A LL A OUT EMPTY LIST LL FOR PAIR APUN NULL L OUT ADD PA OUT ADD PB RET OUT"; S productions = [[ $main := $function $function := $modifiers $typeParameters $returnType $name "(" $args ")" "{" $body "}" $body := repeat0OrMore($statement) $declaration := $type $name "=" $value ";" $statement := $returnStmt | $declaration $returnStmt := "ret" $value ";" ]]; new LS prods2; for (S grammarClass, def : parseColonEqualsProperties_tlftj(productions)) { def = replaceDollarVarsWithAngleBracketed(def); LS tok = javaTokWithAngleBracketsC(def); S def2 = joinWithSpace(withoutQuoted(tok)); S replacement = joinWithSpace("bla"); prods2.add(dropDollarPrefix(grammarClass) + " => " + quote(def2) + " => " + replacement); } new RecursiveProbabilisticParser1 parser; parser.minTokensForAny = 0; //parser.verbose = true; print(recursiveProbabilisticParse(print(lines(prods2)), "function", riddle, +parser)); } }