As far as I can tell, programs with an infinite number of variables can exist:
The number of instructions in a program (including var) is unlimited (based on the grammar).
The number of arguments for each var instruction is unlimited (based on the grammar).
Variable names must be unique (explicitly stated), but this isn't an issue because there's an infinite amount of valid names (because VarName length is unlimited, based on the grammar).
I'd say, you should support an unlimited number because of this.
Theoretically, it should even be possible to compile and run such program, because:
There's an infinite amount of cells to accomodate the variables (explicitly stated).
There's no explicit limit on the size of resulting code.
As a workaround, you can run the final tests instead. For some reason, this error only appears in sample tests
As far as I can tell, programs with an infinite number of variables can exist:
var
) is unlimited (based on the grammar).var
instruction is unlimited (based on the grammar).VarName
length is unlimited, based on the grammar).I'd say, you should support an unlimited number because of this.
Theoretically, it should even be possible to compile and run such program, because:
Description:
and then two blocks of examples returning ASTs.
Return an AST.
There's no whitespace in register or label names.
The tests don't seem to call msg twice - my code inserts newlines when it sees repeat calls.
That violates the rule, hence not allowed.
This is generally known as a recursive descent parser and I'd say it's a good way to do things
Thanks, it's accually the only solution I can figure out when before checked the solusions. LOL
You can make one.