awk: deindent code block, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
adcd9a6f34
commit
a493441ca5
187
editors/awk.c
187
editors/awk.c
@ -1337,8 +1337,9 @@ static node *parse_expr(uint32_t term_tc)
|
|||||||
cn->a.n = glptr;
|
cn->a.n = glptr;
|
||||||
expected_tc = TS_OPERAND | TS_UOPPRE;
|
expected_tc = TS_OPERAND | TS_UOPPRE;
|
||||||
glptr = NULL;
|
glptr = NULL;
|
||||||
|
continue;
|
||||||
} else if (tc & (TS_BINOP | TC_UOPPOST)) {
|
}
|
||||||
|
if (tc & (TS_BINOP | TC_UOPPOST)) {
|
||||||
debug_printf_parse("%s: TS_BINOP | TC_UOPPOST tc:%x\n", __func__, tc);
|
debug_printf_parse("%s: TS_BINOP | TC_UOPPOST tc:%x\n", __func__, tc);
|
||||||
/* for binary and postfix-unary operators, jump back over
|
/* for binary and postfix-unary operators, jump back over
|
||||||
* previous operators with higher priority */
|
* previous operators with higher priority */
|
||||||
@ -1368,101 +1369,103 @@ static node *parse_expr(uint32_t term_tc)
|
|||||||
expected_tc = TS_OPERAND | TS_UOPPRE | TS_BINOP | term_tc;
|
expected_tc = TS_OPERAND | TS_UOPPRE | TS_BINOP | term_tc;
|
||||||
}
|
}
|
||||||
vn->a.n = cn;
|
vn->a.n = cn;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
debug_printf_parse("%s: other, t_info:%x\n", __func__, t_info);
|
||||||
debug_printf_parse("%s: other, t_info:%x\n", __func__, t_info);
|
/* for operands and prefix-unary operators, attach them
|
||||||
/* for operands and prefix-unary operators, attach them
|
* to last node */
|
||||||
* to last node */
|
vn = cn;
|
||||||
vn = cn;
|
cn = vn->r.n = new_node(t_info);
|
||||||
cn = vn->r.n = new_node(t_info);
|
cn->a.n = vn;
|
||||||
cn->a.n = vn;
|
|
||||||
|
|
||||||
expected_tc = TS_OPERAND | TS_UOPPRE | TC_REGEXP;
|
expected_tc = TS_OPERAND | TS_UOPPRE | TC_REGEXP;
|
||||||
if (t_info == TI_PREINC || t_info == TI_PREDEC)
|
if (t_info == TI_PREINC || t_info == TI_PREDEC)
|
||||||
expected_tc = TS_LVALUE | TC_UOPPRE1;
|
expected_tc = TS_LVALUE | TC_UOPPRE1;
|
||||||
if (tc & (TS_OPERAND | TC_REGEXP)) {
|
|
||||||
debug_printf_parse("%s: TS_OPERAND | TC_REGEXP\n", __func__);
|
|
||||||
expected_tc = TS_UOPPRE | TC_UOPPOST | TS_BINOP | TS_OPERAND | term_tc;
|
|
||||||
/* one should be very careful with switch on tclass -
|
|
||||||
* only simple tclasses should be used (TC_xyz, not TS_xyz) */
|
|
||||||
switch (tc) {
|
|
||||||
case TC_VARIABLE:
|
|
||||||
case TC_ARRAY:
|
|
||||||
debug_printf_parse("%s: TC_VARIABLE | TC_ARRAY\n", __func__);
|
|
||||||
cn->info = OC_VAR;
|
|
||||||
v = hash_search(ahash, t_string);
|
|
||||||
if (v != NULL) {
|
|
||||||
cn->info = OC_FNARG;
|
|
||||||
cn->l.aidx = v->x.aidx;
|
|
||||||
} else {
|
|
||||||
cn->l.v = newvar(t_string);
|
|
||||||
}
|
|
||||||
if (tc & TC_ARRAY) {
|
|
||||||
cn->info |= xS;
|
|
||||||
cn->r.n = parse_expr(TC_ARRTERM);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TC_NUMBER:
|
if (!(tc & (TS_OPERAND | TC_REGEXP)))
|
||||||
case TC_STRING:
|
continue;
|
||||||
debug_printf_parse("%s: TC_NUMBER | TC_STRING\n", __func__);
|
|
||||||
cn->info = OC_VAR;
|
|
||||||
v = cn->l.v = xzalloc(sizeof(var));
|
|
||||||
if (tc & TC_NUMBER)
|
|
||||||
setvar_i(v, t_double);
|
|
||||||
else {
|
|
||||||
setvar_s(v, t_string);
|
|
||||||
expected_tc &= ~TC_UOPPOST; /* "str"++ is not allowed */
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TC_REGEXP:
|
debug_printf_parse("%s: TS_OPERAND | TC_REGEXP\n", __func__);
|
||||||
debug_printf_parse("%s: TC_REGEXP\n", __func__);
|
expected_tc = TS_UOPPRE | TC_UOPPOST | TS_BINOP | TS_OPERAND | term_tc;
|
||||||
mk_re_node(t_string, cn, xzalloc(sizeof(regex_t)*2));
|
/* one should be very careful with switch on tclass -
|
||||||
break;
|
* only simple tclasses should be used (TC_xyz, not TS_xyz) */
|
||||||
|
switch (tc) {
|
||||||
case TC_FUNCTION:
|
case TC_VARIABLE:
|
||||||
debug_printf_parse("%s: TC_FUNCTION\n", __func__);
|
case TC_ARRAY:
|
||||||
cn->info = OC_FUNC;
|
debug_printf_parse("%s: TC_VARIABLE | TC_ARRAY\n", __func__);
|
||||||
cn->r.f = newfunc(t_string);
|
cn->info = OC_VAR;
|
||||||
cn->l.n = condition();
|
v = hash_search(ahash, t_string);
|
||||||
break;
|
if (v != NULL) {
|
||||||
|
cn->info = OC_FNARG;
|
||||||
case TC_SEQSTART:
|
cn->l.aidx = v->x.aidx;
|
||||||
debug_printf_parse("%s: TC_SEQSTART\n", __func__);
|
} else {
|
||||||
cn = vn->r.n = parse_expr(TC_SEQTERM);
|
cn->l.v = newvar(t_string);
|
||||||
if (!cn)
|
|
||||||
syntax_error("Empty sequence");
|
|
||||||
cn->a.n = vn;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TC_GETLINE:
|
|
||||||
debug_printf_parse("%s: TC_GETLINE\n", __func__);
|
|
||||||
glptr = cn;
|
|
||||||
expected_tc = TS_OPERAND | TS_UOPPRE | TS_BINOP | term_tc;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TC_BUILTIN:
|
|
||||||
debug_printf_parse("%s: TC_BUILTIN\n", __func__);
|
|
||||||
cn->l.n = condition();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TC_LENGTH:
|
|
||||||
debug_printf_parse("%s: TC_LENGTH\n", __func__);
|
|
||||||
next_token(TC_SEQSTART /* length(...) */
|
|
||||||
| TS_OPTERM /* length; (or newline)*/
|
|
||||||
| TC_GRPTERM /* length } */
|
|
||||||
| TC_BINOPX /* length <op> NUM */
|
|
||||||
| TC_COMMA /* print length, 1 */
|
|
||||||
);
|
|
||||||
rollback_token();
|
|
||||||
if (t_tclass & TC_SEQSTART) {
|
|
||||||
/* It was a "(" token. Handle just like TC_BUILTIN */
|
|
||||||
cn->l.n = condition();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (tc & TC_ARRAY) {
|
||||||
|
cn->info |= xS;
|
||||||
|
cn->r.n = parse_expr(TC_ARRTERM);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TC_NUMBER:
|
||||||
|
case TC_STRING:
|
||||||
|
debug_printf_parse("%s: TC_NUMBER | TC_STRING\n", __func__);
|
||||||
|
cn->info = OC_VAR;
|
||||||
|
v = cn->l.v = xzalloc(sizeof(var));
|
||||||
|
if (tc & TC_NUMBER)
|
||||||
|
setvar_i(v, t_double);
|
||||||
|
else {
|
||||||
|
setvar_s(v, t_string);
|
||||||
|
expected_tc &= ~TC_UOPPOST; /* "str"++ is not allowed */
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TC_REGEXP:
|
||||||
|
debug_printf_parse("%s: TC_REGEXP\n", __func__);
|
||||||
|
mk_re_node(t_string, cn, xzalloc(sizeof(regex_t)*2));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TC_FUNCTION:
|
||||||
|
debug_printf_parse("%s: TC_FUNCTION\n", __func__);
|
||||||
|
cn->info = OC_FUNC;
|
||||||
|
cn->r.f = newfunc(t_string);
|
||||||
|
cn->l.n = condition();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TC_SEQSTART:
|
||||||
|
debug_printf_parse("%s: TC_SEQSTART\n", __func__);
|
||||||
|
cn = vn->r.n = parse_expr(TC_SEQTERM);
|
||||||
|
if (!cn)
|
||||||
|
syntax_error("Empty sequence");
|
||||||
|
cn->a.n = vn;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TC_GETLINE:
|
||||||
|
debug_printf_parse("%s: TC_GETLINE\n", __func__);
|
||||||
|
glptr = cn;
|
||||||
|
expected_tc = TS_OPERAND | TS_UOPPRE | TS_BINOP | term_tc;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TC_BUILTIN:
|
||||||
|
debug_printf_parse("%s: TC_BUILTIN\n", __func__);
|
||||||
|
cn->l.n = condition();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TC_LENGTH:
|
||||||
|
debug_printf_parse("%s: TC_LENGTH\n", __func__);
|
||||||
|
next_token(TC_SEQSTART /* length(...) */
|
||||||
|
| TS_OPTERM /* length; (or newline)*/
|
||||||
|
| TC_GRPTERM /* length } */
|
||||||
|
| TC_BINOPX /* length <op> NUM */
|
||||||
|
| TC_COMMA /* print length, 1 */
|
||||||
|
);
|
||||||
|
rollback_token();
|
||||||
|
if (t_tclass & TC_SEQSTART) {
|
||||||
|
/* It was a "(" token. Handle just like TC_BUILTIN */
|
||||||
|
cn->l.n = condition();
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} /* while() */
|
} /* while() */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user