Skip to content
Snippets Groups Projects
Commit d1d4bbc1 authored by Adam Radziszewski's avatar Adam Radziszewski
Browse files

updated joskipi2wccl rule converter

parent bd777f2f
Branches
No related tags found
No related merge requests found
...@@ -13,11 +13,23 @@ NOTE: this is based on very naive heuristics. ...@@ -13,11 +13,23 @@ NOTE: this is based on very naive heuristics.
# TODO agr bits # TODO agr bits
# TODO isbig -> regex # TODO isbig -> regex
p_brackets = re.compile(u'{(\\s*"[^"]*"(\\s*,\\s*"[^"]*")*\\s*)}', re.U) p_strset = re.compile(u'{(\\s*"[^"]*"(\\s*,\\s*"[^"]*")*\\s*)}', re.U)
p_negposref = re.compile(u'\$\-([0-9]+)([A-Z][A-Za-z0-9]*)')
p_posposref = re.compile(u'\$[\+]?([0-9]+)([A-Z][A-Za-z0-9]*)')
p_isbig = re.compile(u'isbig\(([^)]*)\)', re.U)
p_hasnum = re.compile(u'hasnum\(([^)]*)\)', re.U)
p_agr = re.compile(u'(w?agr[a-z]*)\\s*\(\\s*([\-0-9]+)\\s*,\\s*([\-0-9]+)\\s*,\\s*({[^}]*})\\s*,\\s*([\-0-9]+)\\s*\)', re.U)
def jos2ccl(what): def jos2ccl(what):
what = what.replace('{none}', '{}')
what = what.replace('flex[', 'class[') what = what.replace('flex[', 'class[')
return p_brackets.sub(u'[\\1]', what) what = p_negposref.sub(u'$\\2 - \\1', what)
what = p_posposref.sub(u'$\\2 + \\1', what)
what = p_strset.sub(u'[\\1]', what)
what = p_isbig.sub(u'regex(\\1, "\\\\\\p{Lu}.*")', what)
what = p_hasnum.sub(u'regex(\\1, ".*[0-9].*")', what)
what = p_agr.sub(u'\\1(\\2, \\3, \\4)', what)
return what
class IndentWriter: class IndentWriter:
def __init__(self, out, baseindent = 0): def __init__(self, out, baseindent = 0):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment