More universal read().

portnov [2008-06-21 10:45:35]
More universal read().
Filename
texts.bnf
unibnfgen.py
diff --git a/texts.bnf b/texts.bnf
index 6428b40..226765d 100644
--- a/texts.bnf
+++ b/texts.bnf
@@ -1,3 +1,4 @@
+Text = Period | Period " " Text;
 Period = Statement | Question;
 Question = GeneralQuestion | Doesnt | SpecialQuestion ;
 SpecialQuestion = QWord Helper Subject Predicate Adjective "?";
diff --git a/unibnfgen.py b/unibnfgen.py
index 54a5587..58fb460 100755
--- a/unibnfgen.py
+++ b/unibnfgen.py
@@ -56,13 +56,18 @@ def interpret(s):
   s = s.replace(r'\n','\n')
   return s

-def read():
+def read_one():
   s = raw_input()
+  s = re.sub('#.*','',s)
   s = s.strip()
   if not s:
-    return s
+    return read_one()
+  return s
+
+def read():
+  s = read_one()
   while s[-1] != ';':
-    s += raw_input()
+    s += read_one()
   return s

 yacc.yacc()
@@ -78,7 +83,6 @@ while True:
     s = read()
   except EOFError:
     break
-  s = re.sub('#.*','',s)
   if s == '' : continue
   value = yacc.parse(s)
 #   print ">> Parsed: ",value
ViewGit