@@ -25,13 +25,13 @@ def _split_into_lines(self, tokens):
25
25
26
26
def parse_line (self , line ):
27
27
"""Parses a single line of tokens into a node."""
28
- # print(f"Parsing line: {line}")
28
+ print (f"Parsing line: { line } " )
29
29
if not line :
30
30
return None # handle empty lines
31
31
first_token = line [0 ]
32
32
if first_token .type == Dictionary .KEYWORD and first_token .value == 'if' :
33
33
return self .parse_if_statement (line )
34
- elif first_token .type == Dictionary .IDENTIFIER :
34
+ elif first_token .type == Dictionary .IDENTIFIER or first_token . type == Dictionary . CELL :
35
35
return self .parse_assignment (line )
36
36
else :
37
37
return self .parse_expression (line )
@@ -134,7 +134,6 @@ def parse_if_statement(self, line):
134
134
135
135
def parse_assignment (self , line ):
136
136
"""Parse an assignment statement."""
137
- # Example parsing assuming format `variable = expression`
138
137
# remove whitespace tokens
139
138
tokens = [token for token in line if token .type != Dictionary .WHITE_SPACE ]
140
139
# find the assignment token
@@ -146,6 +145,9 @@ def parse_assignment(self, line):
146
145
if i != 1 :
147
146
raise ValueError ("Invalid assignment statement" )
148
147
variable = tokens [0 ]
148
+ # if the variable is a cell reference, parse it
149
+ if variable .type == Dictionary .CELL :
150
+ variable = self .parse_cell_reference (variable )
149
151
# everything after the assignment token is the expression
150
152
variable_value = tokens [i + 1 :]
151
153
# if we only have 1 token, and it's an identifier, we can return the variable
0 commit comments