Skip to content

Commit

Permalink
Replace single entry command list with its contents
Browse files Browse the repository at this point in the history
This puts things in a more canonical form, which makes subsequent
optimisations easier.
  • Loading branch information
ojwb committed Feb 2, 2021
1 parent b92eb8a commit 9438131
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions compiler/analyser.c
Original file line number Diff line number Diff line change
Expand Up @@ -860,8 +860,20 @@ static struct node * read_C(struct analyser * a) {
struct tokeniser * t = a->tokeniser;
int token = read_token(t);
switch (token) {
case c_bra:
return read_C_list(a);
case c_bra: {
struct node * p = read_C_list(a);
if (p->type != c_bra) {
fprintf(stderr, "read_C_list returned unexpected type %s\n",
name_of_token(p->type));
exit(1);
}
if (p->left && !p->left->right) {
// Replace a single entry command list with the command it
// contains in order to make subsequent optimisations easier.
p = p->left;
}
return p;
}
case c_backwards:
{
int mode = a->mode;
Expand Down

0 comments on commit 9438131

Please sign in to comment.