File tree 2 files changed +14
-6
lines changed
2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,12 @@ def parseBlock():
23
23
def parseCommand ():
24
24
result = None
25
25
26
- if (Parser .tokens .actual .type == 'IDENTIFIER' ):
26
+ if (Parser .tokens .actual .type == "LINE_END" ):
27
+ Parser .tokens .selectNext ()
28
+ if (not result ):
29
+ result = NoOp ()
30
+
31
+ elif (Parser .tokens .actual .type == 'IDENTIFIER' ):
27
32
iden = Parser .tokens .actual .value
28
33
Parser .tokens .selectNext ()
29
34
@@ -47,10 +52,8 @@ def parseCommand():
47
52
else :
48
53
raise NameError ("Expected Parenthesis" )
49
54
50
- if (Parser .tokens .actual .type == "LINE_END" ):
51
- Parser .tokens .selectNext ()
52
- if (not result ):
53
- result = NoOp ()
55
+ else :
56
+ raise NameError (f"Unexpected token { Parser .tokens .actual .type } " )
54
57
55
58
return result
56
59
Original file line number Diff line number Diff line change @@ -36,6 +36,8 @@ def selectNext(self):
36
36
while (self .position < len (self .origin ) and (self .origin [self .position ].isnumeric ())):
37
37
resToken += self .origin [self .position ]
38
38
self .position += 1
39
+ if (self .origin [self .position ].isalpha () or self .origin [self .position ] == "_" ):
40
+ raise NameError ("Error creating number, found character" )
39
41
self .actual = Token (resToken , "INT" )
40
42
41
43
elif (self .origin [self .position ].isalpha ()):
@@ -51,5 +53,8 @@ def selectNext(self):
51
53
self .actual = Token (resToken , "PRINT" )
52
54
else :
53
55
self .actual = Token (resToken , "IDENTIFIER" )
54
-
56
+
57
+ else :
58
+ raise NameError ("Unknown token" )
59
+
55
60
return
You can’t perform that action at this time.
0 commit comments