So in a file, I have display("Hello, World!")
And my code does not line " the ) (yet it still runs).
When I remove it to display("Hello, World!" it runs with no issue.
parser/lexer/what ever its called
if str(tokens[idx][1]).upper() == 'DISPLAY':
if (idx + 2) < len(tokens) and tokens[idx + 1][0] == 'LPAREN' and tokens[idx + 2][0] == 'STRING_LITERAL':
print(get_value(tokens[idx + 2]))
idx += 3
elif (idx + 2) < len(tokens) and tokens[idx + 1][0] == 'LPAREN' and tokens[idx + 2][0] == 'IDENTIFIER':
if (idx + 3) < len(tokens) and tokens[idx + 3][0] == 'RPAREN':
value = get_value(tokens[idx + 2])
if value is not None:
print(value)
else:
raise UndefinedVariable("Undefined Variable: ", tokens[idx + 2][1])
idx += 4 # Skip the closing parenthesis
else:
raise MismatchedParentheses("Mismatched Parentheses For Display Statement")
else:
raise InvalidStatement("Display statement Invalid")