Skip to content

Commit bca0ca0

Browse files
committed
Implement empty statement
1 parent 4c31f49 commit bca0ca0

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

shivyc/parser/statement.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,9 @@ def parse_expr_statement(index):
226226
Ex: a = 3 + 4
227227
228228
"""
229+
if token_is(index, token_kinds.semicolon):
230+
return nodes.EmptyStatement(), index + 1
231+
229232
node, index = parse_expression(index)
230233
index = match_token(index, token_kinds.semicolon, ParserError.AFTER)
231234
return nodes.ExprStatement(node), index

shivyc/tree/nodes.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,18 @@ class Continue(_BreakContinue):
146146
descrip = "continue"
147147

148148

149+
class EmptyStatement(Node):
150+
"""Node for a statement which is just a semicolon."""
151+
152+
def __init__(self):
153+
"""Initialize node."""
154+
super().__init__()
155+
156+
def make_il(self, il_code, symbol_table, c):
157+
"""Nothing to do for a blank statement."""
158+
pass
159+
160+
149161
class ExprStatement(Node):
150162
"""Node for a statement which contains one expression."""
151163

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
int main() {
2+
;;;;;
3+
while(0);
4+
for(;0;);
5+
}

0 commit comments

Comments
 (0)