Add parsing comment syntax.
--- a/py/gadict.py Sat Apr 02 00:26:34 2016 +0300
+++ b/py/gadict.py Sat Apr 02 00:32:23 2016 +0300
@@ -34,6 +34,8 @@
class Parser:
"""gadict dictionary format parser."""
+ COMMENT_RE = regex.compile(r"^# ")
+
SEPARATOR_RE = regex.compile(r"^__$")
HEADWORD_RE = regex.compile(r"^(\p{L}.*)$")
HEADWORD_VAR_RE = regex.compile(r"^ +(s|pl|v[123]|male|female|comp|super)$")
@@ -57,12 +59,16 @@
pass
def readline(self):
- self.line = self.stream.readline()
- self.eof = len(self.line) == 0
- if not self.eof:
- self.lineno += 1
- if self.TRAILING_SPACES_RE.search(self.line):
- raise ParseException("Traling spaces detected...\n")
+ while True:
+ self.line = self.stream.readline()
+ self.eof = len(self.line) == 0
+ if not self.eof:
+ self.lineno += 1
+ if self.TRAILING_SPACES_RE.search(self.line):
+ raise ParseException("Traling spaces detected...\n")
+ if self.COMMENT_RE.search(self.line):
+ continue
+ break
def parse(self, stream):
self.lineno = 0