move the member-of check for '.' to after applying the previous dot operators so we don't need parens around 'a.b' of 'a.b.c = x'

This commit is contained in:
Wolfgang (Blub) Bumiller 2012-08-18 19:42:38 +02:00
parent 0d4e6a2ee8
commit d88e3e8f24
2 changed files with 16 additions and 16 deletions

View file

@ -22,7 +22,7 @@ void() main = {
pawn2 = spawn(); pawn2 = spawn();
pawn.other = pawn2; pawn.other = pawn2;
(pawn.other).vis = 0; pawn.other.vis = 0;
if (!visible(pawn.other)) if (!visible(pawn.other))
print("Yes\n"); print("Yes\n");

View file

@ -1167,6 +1167,21 @@ static ast_expression* parser_expression_leave(parser_t *parser, bool stopatcomm
if (op->id == opid1(',') && !parens && stopatcomma) if (op->id == opid1(',') && !parens && stopatcomma)
break; break;
if (sy.ops_count && !sy.ops[sy.ops_count-1].paren)
olast = &operators[sy.ops[sy.ops_count-1].etype-1];
while (olast && (
(op->prec < olast->prec) ||
(op->assoc == ASSOC_LEFT && op->prec <= olast->prec) ) )
{
if (!parser_sy_pop(parser, &sy))
goto onerr;
if (sy.ops_count && !sy.ops[sy.ops_count-1].paren)
olast = &operators[sy.ops[sy.ops_count-1].etype-1];
else
olast = NULL;
}
if (op->id == opid1('.')) { if (op->id == opid1('.')) {
/* for gmqcc standard: open up the namespace of the previous type */ /* for gmqcc standard: open up the namespace of the previous type */
ast_expression *prevex = sy.out[sy.out_count-1].out; ast_expression *prevex = sy.out[sy.out_count-1].out;
@ -1185,21 +1200,6 @@ static ast_expression* parser_expression_leave(parser_t *parser, bool stopatcomm
gotmemberof = true; gotmemberof = true;
} }
if (sy.ops_count && !sy.ops[sy.ops_count-1].paren)
olast = &operators[sy.ops[sy.ops_count-1].etype-1];
while (olast && (
(op->prec < olast->prec) ||
(op->assoc == ASSOC_LEFT && op->prec <= olast->prec) ) )
{
if (!parser_sy_pop(parser, &sy))
goto onerr;
if (sy.ops_count && !sy.ops[sy.ops_count-1].paren)
olast = &operators[sy.ops[sy.ops_count-1].etype-1];
else
olast = NULL;
}
if (op->id == opid1('(')) { if (op->id == opid1('(')) {
if (wantop) { if (wantop) {
DEBUGSHUNTDO(printf("push (\n")); DEBUGSHUNTDO(printf("push (\n"));