-
Notifications
You must be signed in to change notification settings - Fork 0
/
check.py
executable file
·36 lines (33 loc) · 921 Bytes
/
check.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from error import error
def findLine(content, c):
x = 0
letters = []
for key in content:
if (key[0] == c):
if (x != 0):
error('More than one line starting with ' + c)
i = 1
while (i < len(key)):
if (key[i] not in letters and key[i].isupper()):
letters.append(key[i])
elif (key[i] in letters):
error('More than one ' + key[i] + ' in line starting with ' + c)
else:
error('Unexpected ' + key[i] + ' in line starting with ' + c)
i += 1
x += 1
if (x != 1):
error('No line starting with ' + c)
return letters
def getRules(content):
rules = []
for key in content:
if (key[0].isupper() or key[0] == '!' or key[0] == '('):
rules.append(key)
return rules
def checkLines(content):
i = 1
for key in content:
if (not key[0].isupper() and key[0] != '!' and key[0] != '?' and key[0] != '=' and key[0] != '('):
error('Unexpected syntax line ' + str(i))
i += 1