Commit 229ce642 authored by Per Cederqvist's avatar Per Cederqvist

(reader.check_paren_null): New name for former check_paren_eof. All

	callers updated.  Clear __parenstack, so that errors are
	reported only once.
(lexer.__init__): Initialize __linkhere.
(lexer.toplevel_node): Check that no @linkhere or closing
	parenthesis are pending.
(lexer.toplevel_reqdlink, lexer.__assert_no_linkhere)
(lexer.toplevel_linkhere): New methods.
parent ea401786
......@@ -87,20 +87,22 @@ class reader:
def line_no(self):
return self.__line_no
def check_paren_eof(self):
def check_paren_null(self):
for par, line in self.__parenstack:
self.error(line, "unclosed ``%s''" % par)
self.__parenstack = []
class lexer:
def __init__(self, file):
self.__reader = reader(file)
self.__findex = None
self.__linkhere = None
def run(self):
while 1:
c = self.__reader.getc_eofok()
if c == None:
self.__reader.check_paren_eof()
self.__reader.check_paren_null()
return self.__reader.errfound()
if c == '@':
self.__toplevel_at()
......@@ -190,8 +192,6 @@ class lexer:
toplevel_item = ignore
toplevel_req = ignore
toplevel_reqlink = ignore
toplevel_reqdlink = ignore # FIXME: check matching @linkhere usage
toplevel_linkhere = ignore # FIXME: check matching @reqdlink usage
toplevel_subsection = ignore
toplevel_itemize = ignore
toplevel_bullet = ignore
......@@ -238,6 +238,8 @@ class lexer:
self.__findex = None
self.__node_name = arg
self.__node_start = line_no
self.__assert_no_linkhere()
self.__reader.check_paren_null()
def toplevel_findex(self, arg, line_no):
if self.__node_name != arg:
......@@ -272,6 +274,20 @@ class lexer:
if self.__findex != None:
self.error(self.__reader.line_no(), "unterminated @findex node")
def toplevel_reqdlink(self, arg, line_no):
self.__assert_no_linkhere()
self.__linkhere = ("@reqdlink{%s}" % arg, line_no)
def __assert_no_linkhere(self):
if self.__linkhere != None:
self.error(self.__linkhere[1],
"@linkhere{} after %s missing" % (self.__linkhere[0]))
def toplevel_linkhere(self, arg, line_no):
if self.__linkhere == None:
self.error(line_no, "spurious @linkhere{}")
self.__linkhere = None
def __parse_request(self):
self.__tokens = []
req = self.__get_token()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment