Commit 83391371 authored by Per Cederqvist's avatar Per Cederqvist

(lexer.__init__): Read numbered-requests.tmp.

(lexer.toplevel_findex): Check that the same request name isn't used twice.
(lexer.toplevel_bye): Check that all implemented requests are documented.
(lexer.__parse_request): Check that the proper request number is
	used, and that the request is really implemented.
parent 33cdf6cc
......@@ -222,6 +222,14 @@ class lexer:
self.__tindex_seen = {}
for t in self.__builtin_types:
defined_types[t] = prot_a_builtin('*builtin*')
self.__defined_requests = {}
self.__implemented_reqs = {}
f = open("numbered-requests.tmp", "r")
for line in f.readlines():
[nr, name] = line.split(" ")
self.__implemented_reqs[name.strip()] = nr
f.close()
def run(self):
while 1:
......@@ -377,6 +385,10 @@ class lexer:
return
self.__findex = arg
self.__args = {}
if self.__defined_requests.has_key(arg):
self.error(line_no, "request ``%s'' redefined" % arg)
self.error(self.__defined_requests[arg], "previous definition")
self.__defined_requests[arg] = line_no
if self.__get_token() != '@example':
self.error(self.__reader.line_no(), "missing @example")
return
......@@ -398,10 +410,19 @@ class lexer:
def toplevel_bye(self, arg, line_no):
if self.__findex != None:
self.error(self.__reader.line_no(), "unterminated @findex node")
# Check types.
for (n, o) in defined_types.items():
if o.usage() < 1:
self.error(o.line(), "unused type ``%s''" % n)
# Check requests.
for req in self.__implemented_reqs.keys():
if not self.__defined_requests.has_key(req):
self.error(self.__reader.line_no(),
"request ``%s'' not documented" % req)
def toplevel_reqdlink(self, arg, line_no):
self.__assert_no_linkhere()
self.__linkhere = ("@reqdlink{%s}" % arg, line_no)
......@@ -644,6 +665,15 @@ class lexer:
if type(nr) != types.IntType:
self.error(self.__reader.line_no(), "bad request number")
if self.__implemented_reqs.has_key(req):
if self.__implemented_reqs[req] != str(nr):
self.error(self.__reader.line_no(),
"``%s'' is implemented as request number %s, not %s"
% (req, self.__implemented_reqs[req], nr))
else:
self.error(self.__reader.line_no(),
"request ``%s'' not implemented" % req)
if self.__get_token() != ']':
self.error(self.__reader.line_no(), "missing ``]''")
return
......
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