You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the general current pattern of parsing functions in clox is as follows:
...
if (match(TOKEN_FOR)) { // consumes current token if it matches
for_statement(...)
}
...
void for_statement(...) {
consume(TOKEN_LEFT_PAREN);
...
}
i believe this can a be bit confusing since the parsing of the whole construct (in this example the for statement) is spread over two places (or more in some cases).
i think it might be better to structure parsing functions so that they are self-contained, as follows:
this restructuring adds no additional runtime overhead but can make code more straightforward to grok since all logical steps for parsing a construct are in its corresponding function.
The text was updated successfully, but these errors were encountered:
the general current pattern of parsing functions in
clox
is as follows:i believe this can a be bit confusing since the parsing of the whole construct (in this example the
for
statement) is spread over two places (or more in some cases).i think it might be better to structure parsing functions so that they are self-contained, as follows:
this restructuring adds no additional runtime overhead but can make code more straightforward to grok since all logical steps for parsing a construct are in its corresponding function.
The text was updated successfully, but these errors were encountered: