Commit c752fa27 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(islower): New function. Use it instead of "".islower.

(isspace): New function.  Use it instead of "".isspace.
parent 32f68d0d
......@@ -67,12 +67,24 @@ def isupper(s):
return 0
return 1
def islower(s):
for c in s:
if c not in "abcdefghijklmnopqrstuvwxyz":
return 0
return 1
def isdigit(s):
for c in s:
if c not in "0123456789":
return 0
return 1
def isspace(s):
for c in s:
if c not in " \n": # There should be no \t or \r in this file...
return 0
return 1
class reader_eof(Exception):
pass
......@@ -1127,7 +1139,7 @@ class lexer:
else:
if c == '-':
upper = 1
elif not c.islower():
elif not islower(c):
ok = 0
if ok and tp[-1] == '-':
ok = 0
......@@ -1143,10 +1155,10 @@ class lexer:
ok = 1
if len(arg) < 0:
ok = 0
if ok and not arg[0].islower():
if ok and not islower(arg[0]):
ok = 0
for c in arg[1:]:
if not c.islower() and c != '-':
if not islower(c) and c != '-':
ok = 0
if ok and arg[-1] == '-':
ok = 0
......@@ -1191,7 +1203,7 @@ class lexer:
del self.__tokens[0]
return res
c = self.__reader.getc()
while c.isspace():
while isspace(c):
c = self.__reader.getc()
if isalpha(c):
res = c
......
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