# HG changeset patch # User Oleksandr Gavenko # Date 1459546343 -10800 # Node ID b3a78fc20b314e2fad5203b520550783fa0b329f # Parent 4ec7d0ea16028ba83a07c3f42f5a4913cd468572 Add parsing comment syntax. diff -r 4ec7d0ea1602 -r b3a78fc20b31 py/gadict.py --- 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