aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2021-07-03 00:39:55 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2021-07-03 00:39:55 +0200
commit717200eb43c9420773c0f8b751aadabba3052027 (patch)
treed3818f30dd030130e5cc87676f142acb1960ed35
parentb705bf55395bf338f9b9888d87e418f67d4f1a29 (diff)
downloadbusybox-w32-717200eb43c9420773c0f8b751aadabba3052027.tar.gz
busybox-w32-717200eb43c9420773c0f8b751aadabba3052027.tar.bz2
busybox-w32-717200eb43c9420773c0f8b751aadabba3052027.zip
awk: rename GRPSTART/END to L/RBRACE, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--editors/awk.c60
1 files changed, 33 insertions, 27 deletions
diff --git a/editors/awk.c b/editors/awk.c
index 96e06db25..a1a2afd1d 100644
--- a/editors/awk.c
+++ b/editors/awk.c
@@ -211,8 +211,8 @@ typedef struct tsplitter_s {
211#define TC_PIPE (1 << 9) /* input redirection pipe | */ 211#define TC_PIPE (1 << 9) /* input redirection pipe | */
212#define TC_UOPPRE2 (1 << 10) /* unary prefix operator + - ! */ 212#define TC_UOPPRE2 (1 << 10) /* unary prefix operator + - ! */
213#define TC_ARRTERM (1 << 11) /* ] */ 213#define TC_ARRTERM (1 << 11) /* ] */
214#define TC_GRPSTART (1 << 12) /* { */ 214#define TC_LBRACE (1 << 12) /* { */
215#define TC_GRPTERM (1 << 13) /* } */ 215#define TC_RBRACE (1 << 13) /* } */
216#define TC_SEMICOL (1 << 14) /* ; */ 216#define TC_SEMICOL (1 << 14) /* ; */
217#define TC_NEWLINE (1 << 15) 217#define TC_NEWLINE (1 << 15)
218#define TC_STATX (1 << 16) /* ctl statement (for, next...) */ 218#define TC_STATX (1 << 16) /* ctl statement (for, next...) */
@@ -250,8 +250,8 @@ if ((n) & TC_COMMA ) debug_printf_parse(" COMMA" ); \
250if ((n) & TC_PIPE ) debug_printf_parse(" PIPE" ); \ 250if ((n) & TC_PIPE ) debug_printf_parse(" PIPE" ); \
251if ((n) & TC_UOPPRE2 ) debug_printf_parse(" UOPPRE2" ); \ 251if ((n) & TC_UOPPRE2 ) debug_printf_parse(" UOPPRE2" ); \
252if ((n) & TC_ARRTERM ) debug_printf_parse(" ARRTERM" ); \ 252if ((n) & TC_ARRTERM ) debug_printf_parse(" ARRTERM" ); \
253if ((n) & TC_GRPSTART) debug_printf_parse(" GRPSTART"); \ 253if ((n) & TC_LBRACE ) debug_printf_parse(" LBRACE" ); \
254if ((n) & TC_GRPTERM ) debug_printf_parse(" GRPTERM" ); \ 254if ((n) & TC_RBRACE ) debug_printf_parse(" RBRACE" ); \
255if ((n) & TC_SEMICOL ) debug_printf_parse(" SEMICOL" ); \ 255if ((n) & TC_SEMICOL ) debug_printf_parse(" SEMICOL" ); \
256if ((n) & TC_NEWLINE ) debug_printf_parse(" NEWLINE" ); \ 256if ((n) & TC_NEWLINE ) debug_printf_parse(" NEWLINE" ); \
257if ((n) & TC_STATX ) debug_printf_parse(" STATX" ); \ 257if ((n) & TC_STATX ) debug_printf_parse(" STATX" ); \
@@ -291,13 +291,13 @@ if ((n) & TC_NUMBER ) debug_printf_parse(" NUMBER" ); \
291 | TC_FUNCDECL | TC_BEGIN | TC_END) 291 | TC_FUNCDECL | TC_BEGIN | TC_END)
292 292
293/* discard newlines after these */ 293/* discard newlines after these */
294#define TS_NOTERM (TC_COMMA | TC_GRPSTART | TC_GRPTERM \ 294#define TS_NOTERM (TC_COMMA | TC_LBRACE | TC_RBRACE \
295 | TS_BINOP | TS_OPTERM) 295 | TS_BINOP | TS_OPTERM)
296 296
297/* what can expression begin with */ 297/* what can expression begin with */
298#define TS_OPSEQ (TS_OPERAND | TS_UOPPRE | TC_REGEXP) 298#define TS_OPSEQ (TS_OPERAND | TS_UOPPRE | TC_REGEXP)
299/* what can group begin with */ 299/* what can group begin with */
300#define TS_GRPSEQ (TS_OPSEQ | TS_OPTERM | TS_STATEMNT | TC_GRPSTART) 300#define TS_GRPSEQ (TS_OPSEQ | TS_OPTERM | TS_STATEMNT | TC_LBRACE)
301 301
302/* if previous token class is CONCAT_L and next is CONCAT_R, concatenation */ 302/* if previous token class is CONCAT_L and next is CONCAT_R, concatenation */
303/* operator is inserted between them */ 303/* operator is inserted between them */
@@ -402,8 +402,8 @@ static const char tokenlist[] ALIGN1 =
402 "\1|" NTC /* TC_PIPE */ 402 "\1|" NTC /* TC_PIPE */
403 "\1+" "\1-" "\1!" NTC /* TC_UOPPRE2 */ 403 "\1+" "\1-" "\1!" NTC /* TC_UOPPRE2 */
404 "\1]" NTC /* TC_ARRTERM */ 404 "\1]" NTC /* TC_ARRTERM */
405 "\1{" NTC /* TC_GRPSTART */ 405 "\1{" NTC /* TC_LBRACE */
406 "\1}" NTC /* TC_GRPTERM */ 406 "\1}" NTC /* TC_RBRACE */
407 "\1;" NTC /* TC_SEMICOL */ 407 "\1;" NTC /* TC_SEMICOL */
408 "\1\n" NTC /* TC_NEWLINE */ 408 "\1\n" NTC /* TC_NEWLINE */
409 "\2if" "\2do" "\3for" "\5break" /* TC_STATX */ 409 "\2if" "\2do" "\3for" "\5break" /* TC_STATX */
@@ -1471,7 +1471,7 @@ static node *parse_expr(uint32_t term_tc)
1471 debug_printf_parse("%s: TC_LENGTH\n", __func__); 1471 debug_printf_parse("%s: TC_LENGTH\n", __func__);
1472 tc = next_token(TC_LPAREN /* length(...) */ 1472 tc = next_token(TC_LPAREN /* length(...) */
1473 | TS_OPTERM /* length; (or newline)*/ 1473 | TS_OPTERM /* length; (or newline)*/
1474 | TC_GRPTERM /* length } */ 1474 | TC_RBRACE /* length } */
1475 | TC_BINOPX /* length <op> NUM */ 1475 | TC_BINOPX /* length <op> NUM */
1476 | TC_COMMA /* print length, 1 */ 1476 | TC_COMMA /* print length, 1 */
1477 ); 1477 );
@@ -1516,11 +1516,11 @@ static void chain_expr(uint32_t info)
1516 1516
1517 n = chain_node(info); 1517 n = chain_node(info);
1518 1518
1519 n->l.n = parse_expr(TS_OPTERM | TC_GRPTERM); 1519 n->l.n = parse_expr(TS_OPTERM | TC_RBRACE);
1520 if ((info & OF_REQUIRED) && !n->l.n) 1520 if ((info & OF_REQUIRED) && !n->l.n)
1521 syntax_error(EMSG_TOO_FEW_ARGS); 1521 syntax_error(EMSG_TOO_FEW_ARGS);
1522 1522
1523 if (t_tclass & TC_GRPTERM) 1523 if (t_tclass & TC_RBRACE)
1524 rollback_token(); 1524 rollback_token();
1525} 1525}
1526 1526
@@ -1559,16 +1559,16 @@ static void chain_group(void)
1559 c = next_token(TS_GRPSEQ); 1559 c = next_token(TS_GRPSEQ);
1560 } while (c & TC_NEWLINE); 1560 } while (c & TC_NEWLINE);
1561 1561
1562 if (c & TC_GRPSTART) { 1562 if (c & TC_LBRACE) {
1563 debug_printf_parse("%s: TC_GRPSTART\n", __func__); 1563 debug_printf_parse("%s: TC_LBRACE\n", __func__);
1564 while ((c = next_token(TS_GRPSEQ | TC_GRPTERM)) != TC_GRPTERM) { 1564 while ((c = next_token(TS_GRPSEQ | TC_RBRACE)) != TC_RBRACE) {
1565 debug_printf_parse("%s: !TC_GRPTERM\n", __func__); 1565 debug_printf_parse("%s: !TC_RBRACE\n", __func__);
1566 if (c & TC_NEWLINE) 1566 if (c & TC_NEWLINE)
1567 continue; 1567 continue;
1568 rollback_token(); 1568 rollback_token();
1569 chain_group(); 1569 chain_group();
1570 } 1570 }
1571 debug_printf_parse("%s: TC_GRPTERM\n", __func__); 1571 debug_printf_parse("%s: TC_RBRACE\n", __func__);
1572 return; 1572 return;
1573 } 1573 }
1574 if (c & (TS_OPSEQ | TS_OPTERM)) { 1574 if (c & (TS_OPSEQ | TS_OPTERM)) {
@@ -1588,7 +1588,7 @@ static void chain_group(void)
1588 chain_group(); 1588 chain_group();
1589 n2 = chain_node(OC_EXEC); 1589 n2 = chain_node(OC_EXEC);
1590 n->r.n = seq->last; 1590 n->r.n = seq->last;
1591 if (next_token(TS_GRPSEQ | TC_GRPTERM | TC_ELSE) == TC_ELSE) { 1591 if (next_token(TS_GRPSEQ | TC_RBRACE | TC_ELSE) == TC_ELSE) {
1592 chain_group(); 1592 chain_group();
1593 n2->a.n = seq->last; 1593 n2->a.n = seq->last;
1594 } else { 1594 } else {
@@ -1641,12 +1641,12 @@ static void chain_group(void)
1641 case OC_PRINTF: 1641 case OC_PRINTF:
1642 debug_printf_parse("%s: OC_PRINT[F]\n", __func__); 1642 debug_printf_parse("%s: OC_PRINT[F]\n", __func__);
1643 n = chain_node(t_info); 1643 n = chain_node(t_info);
1644 n->l.n = parse_expr(TS_OPTERM | TC_OUTRDR | TC_GRPTERM); 1644 n->l.n = parse_expr(TS_OPTERM | TC_OUTRDR | TC_RBRACE);
1645 if (t_tclass & TC_OUTRDR) { 1645 if (t_tclass & TC_OUTRDR) {
1646 n->info |= t_info; 1646 n->info |= t_info;
1647 n->r.n = parse_expr(TS_OPTERM | TC_GRPTERM); 1647 n->r.n = parse_expr(TS_OPTERM | TC_RBRACE);
1648 } 1648 }
1649 if (t_tclass & TC_GRPTERM) 1649 if (t_tclass & TC_RBRACE)
1650 rollback_token(); 1650 rollback_token();
1651 break; 1651 break;
1652 1652
@@ -1684,7 +1684,7 @@ static void parse_program(char *p)
1684 1684
1685 g_pos = p; 1685 g_pos = p;
1686 t_lineno = 1; 1686 t_lineno = 1;
1687 while ((tclass = next_token(TC_EOF | TS_OPSEQ | TC_GRPSTART | 1687 while ((tclass = next_token(TC_EOF | TS_OPSEQ | TC_LBRACE |
1688 TS_OPTERM | TC_BEGIN | TC_END | TC_FUNCDECL)) != TC_EOF) { 1688 TS_OPTERM | TC_BEGIN | TC_END | TC_FUNCDECL)) != TC_EOF) {
1689 1689
1690 if (tclass & TS_OPTERM) { 1690 if (tclass & TS_OPTERM) {
@@ -1696,10 +1696,14 @@ static void parse_program(char *p)
1696 if (tclass & TC_BEGIN) { 1696 if (tclass & TC_BEGIN) {
1697 debug_printf_parse("%s: TC_BEGIN\n", __func__); 1697 debug_printf_parse("%s: TC_BEGIN\n", __func__);
1698 seq = &beginseq; 1698 seq = &beginseq;
1699//TODO: ensure there is no newline between BEGIN and {
1700//next_token(TC_LBRACE); rollback_token();
1699 chain_group(); 1701 chain_group();
1700 } else if (tclass & TC_END) { 1702 } else if (tclass & TC_END) {
1701 debug_printf_parse("%s: TC_END\n", __func__); 1703 debug_printf_parse("%s: TC_END\n", __func__);
1702 seq = &endseq; 1704 seq = &endseq;
1705//TODO: ensure there is no newline between END and {
1706//next_token(TC_LBRACE); rollback_token();
1703 chain_group(); 1707 chain_group();
1704 } else if (tclass & TC_FUNCDECL) { 1708 } else if (tclass & TC_FUNCDECL) {
1705 debug_printf_parse("%s: TC_FUNCDECL\n", __func__); 1709 debug_printf_parse("%s: TC_FUNCDECL\n", __func__);
@@ -1726,24 +1730,26 @@ static void parse_program(char *p)
1726 /* it was a comma, we ate it */ 1730 /* it was a comma, we ate it */
1727 } 1731 }
1728 seq = &f->body; 1732 seq = &f->body;
1733//TODO: ensure there is { after "func F(...)" - but newlines are allowed
1734//while (next_token(TC_LBRACE | TC_NEWLINE) == TC_NEWLINE) continue; rollback_token();
1729 chain_group(); 1735 chain_group();
1730 hash_clear(ahash); 1736 hash_clear(ahash);
1731 } else if (tclass & TS_OPSEQ) { 1737 } else if (tclass & TS_OPSEQ) {
1732 debug_printf_parse("%s: TS_OPSEQ\n", __func__); 1738 debug_printf_parse("%s: TS_OPSEQ\n", __func__);
1733 rollback_token(); 1739 rollback_token();
1734 cn = chain_node(OC_TEST); 1740 cn = chain_node(OC_TEST);
1735 cn->l.n = parse_expr(TS_OPTERM | TC_EOF | TC_GRPSTART); 1741 cn->l.n = parse_expr(TS_OPTERM | TC_EOF | TC_LBRACE);
1736 if (t_tclass & TC_GRPSTART) { 1742 if (t_tclass & TC_LBRACE) {
1737 debug_printf_parse("%s: TC_GRPSTART\n", __func__); 1743 debug_printf_parse("%s: TC_LBRACE\n", __func__);
1738 rollback_token(); 1744 rollback_token();
1739 chain_group(); 1745 chain_group();
1740 } else { 1746 } else {
1741 debug_printf_parse("%s: !TC_GRPSTART\n", __func__); 1747 debug_printf_parse("%s: !TC_LBRACE\n", __func__);
1742 chain_node(OC_PRINT); 1748 chain_node(OC_PRINT);
1743 } 1749 }
1744 cn->r.n = mainseq.last; 1750 cn->r.n = mainseq.last;
1745 } else /* if (tclass & TC_GRPSTART) */ { 1751 } else /* if (tclass & TC_LBRACE) */ {
1746 debug_printf_parse("%s: TC_GRPSTART(?)\n", __func__); 1752 debug_printf_parse("%s: TC_LBRACE(?)\n", __func__);
1747 rollback_token(); 1753 rollback_token();
1748 chain_group(); 1754 chain_group();
1749 } 1755 }