diff --git a/tools/ruljos2wccl.py b/tools/ruljos2wccl.py index 4d15451d8d0ae17b85f670675f646c65d616f053..5ccc2529acef4949cedb5388ba06abe980b45424 100755 --- a/tools/ruljos2wccl.py +++ b/tools/ruljos2wccl.py @@ -7,11 +7,14 @@ from StringIO import StringIO descr = """%prog [options] IN OUT Attempts to convert JOSKIPI rules to WCCL rules. -NOTE: this is based on very naive heuristics. +NOTE: this is based on very naive heuristics. Dirty regex manipulation is done +instead of real parsing. + +Known issues: +1. Will not skip superfluous none in non-empty sets. +2. Complex agreement/hasnum/isbig predicates will not be handled properly. """ -# TODO agr bits -# TODO isbig -> regex p_strset = re.compile(u'{(\\s*"[^"]*"(\\s*,\\s*"[^"]*")*\\s*)}', re.U) p_negposref = re.compile(u'\$\-([0-9]+)([A-Z][A-Za-z0-9]*)') @@ -58,11 +61,11 @@ class Rule: self.act = jos2ccl(act.strip()) self.name = name.strip() - def write(self, out, comma = False): + def write(self, out, sep = False): out.write('rule("%s",\n' % self.name) out.write('%s,\n' % self.cond) out.write('%s\n' % self.act) - out.write(')%s\n' % (',' if comma else '')) + out.write(')%s\n' % (';' if sep else '')) def rule_texts(infile): buf = StringIO() @@ -97,7 +100,7 @@ def go(): w = IndentWriter(outf) indent = 0 - w.write('rules(\n') + w.write('tag_rules(\n') # quick and dirty: to get all but last allrules = [r for r in rules(inf)] for rule in allrules[:-1]: