summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Korostil <ted.korostiled@gmail.com>2012-06-22 05:46:56 +0300
committerDaniel Korostil <ted.korostiled@gmail.com>2012-06-22 05:46:56 +0300
commitf21ad74d522960a13540496504a5c936ac75a7de (patch)
tree71ff6aea7eefe31beafb92d16c3a2a8f3b6c3c58
parente838b8497c9c6c8634a7d8a5f642a9098622f502 (diff)
removed old files and updated converter to parse upcoming marker tag
-rw-r--r--src/converter/xml2reexp.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/converter/xml2reexp.py b/src/converter/xml2reexp.py
index fc235c3..93e29e0 100644
--- a/src/converter/xml2reexp.py
+++ b/src/converter/xml2reexp.py
@@ -1,6 +1,6 @@
import xml.etree.ElementTree as ET
-tree = ET.parse("grammar.xml") # parsing grammar.xml into an ElementTree instance
+tree = ET.parse("1.xml") # parsing grammar.xml into an ElementTree instance
# list all rules with simple tokens
for rule in tree.iter("rule"): # cycle for all <rule> elements of grammar.xml, variable rule contains the data of the actual element
@@ -10,6 +10,14 @@ for rule in tree.iter("rule"): # cycle for all <rule> elements of grammar.xml,
simple = False # the rule is not simple
if simple:
for token in rule.iter("token"):
- print "(%s)" % token.text,
- print "->", rule.find('message').find('suggestion').text, "# Did you mean?"
-
+ for child in rule:
+ if child.tag == 'token':
+ print "%s" % child.text
+ elif child.tag == 'marker':
+ print "("
+ for subchild in child:
+ if subchild.tag == 'token':
+ print "%s" % subchild.text
+ print ")"
+ print "%s" % token.text,
+ print "->", rule.find('message').find('suggestion').text, "# Did you mean?" \ No newline at end of file