Skip to content

Commit

Permalink
Fix bug in range parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
nickg committed Jun 8, 2014
1 parent 565f5a1 commit 7fd70c8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 20 deletions.
1 change: 0 additions & 1 deletion src/lexer.l
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,6 @@ RRANGE {R}{E}{V}{E}{R}{S}{E}_{R}{A}{N}{G}{E}
{LITERAL} { TOKEN(tLITERAL); }
{GROUP} { TOKEN(tGROUP); }
{LABEL} { TOKEN(tLABEL); }
{RRANGE} { TOKEN(tRRANGE); }

"(" { TOKEN(tLPAREN); }
")" { TOKEN(tRPAREN); }
Expand Down
23 changes: 6 additions & 17 deletions src/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,11 @@ static tree_t p_attribute_name(tree_t prefix)

tree_t t = tree_new(T_ATTR_REF);
tree_set_name(t, prefix);
tree_set_ident(t, p_identifier());

if (optional(tRANGE))
tree_set_ident(t, ident_new("RANGE"));
else
tree_set_ident(t, p_identifier());

return t;
}
Expand Down Expand Up @@ -693,7 +697,7 @@ static range_t p_range(tree_t left)

range_t r = {};

switch (one_of(tTO, tDOWNTO, tTICK)) {
switch (one_of(tTO, tDOWNTO)) {
case tTO:
r.left = left;
r.kind = RANGE_TO;
Expand All @@ -705,21 +709,6 @@ static range_t p_range(tree_t left)
r.left = left;
r.right = p_expression();
break;

case tTICK:
{
switch (one_of(tRANGE, tRRANGE)) {
case tRANGE:
r.left = left;
r.kind = RANGE_EXPR;
break;

case tRRANGE:
r.right = left;
r.kind = RANGE_EXPR;
break;
}
}
}

return r;
Expand Down
3 changes: 1 addition & 2 deletions src/token.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,7 @@ typedef enum {
tREM,
tABS,
tNOT,
tTIMES,
tRRANGE
tTIMES
} token_t;

#endif

0 comments on commit 7fd70c8

Please sign in to comment.