-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Currently, Pulzar sometimes is duplicating child nodes from body scope to main scope. This happens in nested loops and condtional statements. Here is example of code doing this:
Program Console;
float g = 9.81;
int i = 0;
int n = 5;
for i :: i < n :: i++ {
for j :: j < n :: j++ {
echo i;
}
}
Pulzar language will produce AST like this, where builtin function echo is duplicated:
{'main_scope': [{'program': [{'type': 'Console'}]}, {'variable_declaration': [{'type': 'float'}, {'name': 'g'}, {'value': 9.81}]}, {'variable_declaration': [{'type': 'int'}, {'name': 'i'}, {'value': 0}]}, {'variable_declaration': [{'type': 'int'}, {'name': 'n'}, {'value': 5}]}, {'loop': [{'keyword': 'for'}, {'name': 'i'}, {'start_value': 0}, {'end_value': 'n'}, {'increment': '1'}, {'scope': [{'loop': [{'keyword': 'for'}, {'name': 'j'}, {'start_value': None}, {'end_value': 'n'}, {'increment': '1'}, {'scope': [{'builtin_function': [{'function': 'echo'}, {'argument': 'i'}]}]}]}]}]}, {'builtin_function': [{'function': 'echo'}, {'argument': 'i'}]}]}
Therefore it will generate invalid code with print function 2 times insted of ones:
g = 9.81
i = 0
n = 5
for i in range(0, n, 1):
for j in range(0, n, 1):
print(i)
print(i)
This bug is somewhere in the mparser.py. Probably somthing doesn't increases tokens_checked and/or self.token_index.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working