enhanced the awk parser to allow a semicolon after a pattern-action block
This commit is contained in:
parent
4a66396482
commit
4cac6034a8
@ -928,6 +928,10 @@ retry:
|
||||
awk->parse.id.block = PARSE_ACTION_BLOCK;
|
||||
if (parse_action_block (
|
||||
awk, QSE_NULL, QSE_FALSE) == QSE_NULL) return QSE_NULL;
|
||||
|
||||
/* skip a semicolon after an action block if any */
|
||||
if (MATCH(awk,TOK_SEMICOLON) &&
|
||||
get_token (awk) <= -1) return QSE_NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -941,6 +945,7 @@ retry:
|
||||
pattern, pattern
|
||||
*/
|
||||
qse_awk_nde_t* ptn;
|
||||
qse_awk_loc_t eloc;
|
||||
|
||||
if ((awk->option & QSE_AWK_PABLOCK) == 0)
|
||||
{
|
||||
@ -950,10 +955,8 @@ retry:
|
||||
|
||||
awk->parse.id.block = PARSE_PATTERN;
|
||||
|
||||
{
|
||||
qse_awk_loc_t eloc = awk->tok.loc;
|
||||
ptn = parse_expr_dc (awk, &eloc);
|
||||
}
|
||||
eloc = awk->tok.loc;
|
||||
ptn = parse_expr_dc (awk, &eloc);
|
||||
if (ptn == QSE_NULL) return QSE_NULL;
|
||||
|
||||
QSE_ASSERT (ptn->next == QSE_NULL);
|
||||
@ -966,10 +969,9 @@ retry:
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
{
|
||||
qse_awk_loc_t eloc = awk->tok.loc;
|
||||
ptn->next = parse_expr_dc (awk, &eloc);
|
||||
}
|
||||
eloc = awk->tok.loc;
|
||||
ptn->next = parse_expr_dc (awk, &eloc);
|
||||
|
||||
if (ptn->next == QSE_NULL)
|
||||
{
|
||||
qse_awk_clrpt (awk, ptn);
|
||||
@ -977,10 +979,10 @@ retry:
|
||||
}
|
||||
}
|
||||
|
||||
if (MATCH(awk,TOK_NEWLINE) || MATCH(awk,TOK_EOF))
|
||||
if (MATCH(awk,TOK_NEWLINE) || MATCH(awk,TOK_SEMICOLON) || MATCH(awk,TOK_EOF))
|
||||
{
|
||||
/* blockless pattern */
|
||||
qse_bool_t newline = MATCH(awk,TOK_NEWLINE);
|
||||
qse_bool_t eof = MATCH(awk,TOK_EOF);
|
||||
qse_awk_loc_t ploc = awk->ptok.loc;
|
||||
|
||||
awk->parse.id.block = PARSE_ACTION_BLOCK;
|
||||
@ -990,11 +992,11 @@ retry:
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
if (newline)
|
||||
if (!eof)
|
||||
{
|
||||
if (get_token(awk) <= -1)
|
||||
{
|
||||
/* ptn has been added to the chain.
|
||||
/* 'ptn' has been added to the chain.
|
||||
* it doesn't have to be cleared here
|
||||
* as qse_awk_clear does it */
|
||||
/*qse_awk_clrpt (awk, ptn);*/
|
||||
@ -1027,6 +1029,10 @@ retry:
|
||||
qse_awk_clrpt (awk, ptn);
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
/* skip a semicolon after an action block if any */
|
||||
if (MATCH(awk,TOK_SEMICOLON) &&
|
||||
get_token (awk) <= -1) return QSE_NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,8 +3,10 @@ BEGIN {
|
||||
# numbers for a single circuit ID
|
||||
max_cid_vars = 100;
|
||||
|
||||
datapath = datadir "/" datafile;
|
||||
|
||||
first = 1;
|
||||
while ((getline x < datafile) > 0)
|
||||
while ((getline x < datapath) > 0)
|
||||
{
|
||||
# check if it is the first line.
|
||||
if (first)
|
||||
|
1
qse/regress/awk/lang-046.awk
Normal file
1
qse/regress/awk/lang-046.awk
Normal file
@ -0,0 +1 @@
|
||||
1; ((getline < (datadir "/" datafile)) >= 0)
|
6
qse/regress/awk/lang-046.dat1
Normal file
6
qse/regress/awk/lang-046.dat1
Normal file
@ -0,0 +1,6 @@
|
||||
1 AAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
1 BBBBBBBBBBBBBBBBBBBBBBBBB
|
||||
1 CCCCCCCCCCCCCCCCCCCCCCCCC
|
||||
1 DDDDDDDDDDDDDDDDDDDDDDDDD
|
||||
1 EEEEEEEEEEEEEEEEEEEEEEEEE
|
||||
1 FFFFFFFFFFFFFFFFFFFFFFFFF
|
4
qse/regress/awk/lang-046.dat2
Normal file
4
qse/regress/awk/lang-046.dat2
Normal file
@ -0,0 +1,4 @@
|
||||
2 AAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
2 BBBBBBBBBBBBBBBBBBBBBBBBB
|
||||
2 CCCCCCCCCCCCCCCCCCCCCCCCC
|
||||
2 DDDDDDDDDDDDDDDDDDDDDDDDD
|
@ -1736,12 +1736,13 @@ xx: 13
|
||||
xx: 14
|
||||
xx: 15
|
||||
--------------------------------------------------------------------------------
|
||||
[CMD] qseawk --newline=on -d- -vdatafile=lang-035.dat1 -vgroupname=lang-035 -f lang-035.awk lang-035.dat2 </dev/stdin 2>&1
|
||||
[CMD] qseawk --newline=on -d- -vdatadir=/home/hyung-hwan/nfs.exports/workspace/qse/x86_64/linux-wchar-debug/../../src/regress/awk -vdatafile=lang-035.dat1 -vgroupname=lang-035 -f lang-035.awk lang-035.dat2 </dev/stdin 2>&1
|
||||
--------------------------------------------------------------------------------
|
||||
BEGIN {
|
||||
max_cid_vars = 100;
|
||||
datapath = ((datadir "/") datafile);
|
||||
first = 1;
|
||||
while (((getline x < datafile) > 0))
|
||||
while (((getline x < datapath) > 0))
|
||||
{
|
||||
if (first)
|
||||
{
|
||||
@ -1815,6 +1816,7 @@ lease 20.1.20.57 {
|
||||
next binding state free;
|
||||
hardware ethernet 00:13:5e:50:23:6b;
|
||||
info awk.groupname "lang-035";
|
||||
info awk.voice-no-0 "68599021";
|
||||
option agent.circuit-id "BLM1500_AR3_ILAB ONT/9/1/1 /0.0";
|
||||
option agent.unknown-9 0:0:0:c1:8:45:52:49:43:53:53:4f:4e;
|
||||
}
|
||||
@ -1826,6 +1828,7 @@ lease 20.1.20.54 {
|
||||
next binding state free;
|
||||
hardware ethernet 00:13:5e:50:25:aa;
|
||||
info awk.groupname "lang-035";
|
||||
info awk.voice-no-0 "68599011";
|
||||
option agent.circuit-id "BLM1500_AR3_ILAB ONT/9/1/2 /0.0";
|
||||
option agent.unknown-9 0:0:0:c1:8:45:52:49:43:53:53:4f:4e;
|
||||
}
|
||||
@ -1837,6 +1840,7 @@ lease 20.1.20.55 {
|
||||
next binding state free;
|
||||
hardware ethernet 00:13:5e:50:20:af;
|
||||
info awk.groupname "lang-035";
|
||||
info awk.voice-no-0 "68599012";
|
||||
option agent.circuit-id "BLM1500_AR3_ILAB ONT/9/2/1 /0.0";
|
||||
option agent.unknown-9 0:0:0:c1:8:45:52:49:43:53:53:4f:4e;
|
||||
}
|
||||
@ -1848,6 +1852,7 @@ lease 20.1.20.56 {
|
||||
next binding state free;
|
||||
hardware ethernet 00:13:5e:50:20:29;
|
||||
info awk.groupname "lang-035";
|
||||
info awk.voice-no-0 "68599022";
|
||||
option agent.circuit-id "BLM1500_AR3_ILAB ONT/9/2/2 /0.0";
|
||||
option agent.unknown-9 0:0:0:c1:8:45:52:49:43:53:53:4f:4e;
|
||||
}
|
||||
@ -1900,6 +1905,8 @@ lease 10.218.255.55 {
|
||||
hardware ethernet 00:1b:5b:9c:90:00;
|
||||
info awk.groupname "lang-035";
|
||||
uid "\001\000\033[\234\220\000";
|
||||
info awk.voice-no-0 "68599019";
|
||||
info awk.voice-no-1 "68599014";
|
||||
option agent.circuit-id "AR_Remote atm 1/1/03/12:2.100";
|
||||
option agent.remote-id "22M-fast";
|
||||
}
|
||||
@ -1942,6 +1949,7 @@ lease 10.218.255.66 {
|
||||
hardware ethernet 00:1a:04:f9:e2:90;
|
||||
info awk.groupname "lang-035";
|
||||
uid "\001\000\032\004\371\342\220";
|
||||
info awk.voice-no-0 "68599018";
|
||||
option agent.circuit-id "AR_Remote atm 1/1/03/02:2.100";
|
||||
option agent.remote-id "3play";
|
||||
}
|
||||
@ -1954,6 +1962,8 @@ lease 10.218.255.60 {
|
||||
hardware ethernet 00:1e:c7:fb:29:1d;
|
||||
info awk.groupname "lang-035";
|
||||
uid "\001\000\036\307\373)\035";
|
||||
info awk.voice-no-0 "68599017";
|
||||
info awk.voice-no-1 "68599013";
|
||||
option agent.circuit-id "AL_AM3_LAB atm 1/1/01/01:2.100";
|
||||
option agent.remote-id "Testing DHCP";
|
||||
}
|
||||
@ -2336,6 +2346,21 @@ nan
|
||||
8103.08
|
||||
3
|
||||
--------------------------------------------------------------------------------
|
||||
[CMD] qseawk --newline=on -d- -vdatadir=/home/hyung-hwan/nfs.exports/workspace/qse/x86_64/linux-wchar-debug/../../src/regress/awk -vdatafile=lang-046.dat1 -f lang-046.awk lang-046.dat2 </dev/stdin 2>&1
|
||||
--------------------------------------------------------------------------------
|
||||
1
|
||||
|
||||
((getline < ((datadir "/") datafile)) >= 0)
|
||||
|
||||
2 AAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
1 AAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
2 BBBBBBBBBBBBBBBBBBBBBBBBB
|
||||
1 BBBBBBBBBBBBBBBBBBBBBBBBB
|
||||
2 CCCCCCCCCCCCCCCCCCCCCCCCC
|
||||
1 CCCCCCCCCCCCCCCCCCCCCCCCC
|
||||
2 DDDDDDDDDDDDDDDDDDDDDDDDD
|
||||
1 DDDDDDDDDDDDDDDDDDDDDDDDD
|
||||
--------------------------------------------------------------------------------
|
||||
[CMD] qseawk --newline=on -F: -f columnate.awk passwd.dat </dev/stdin 2>&1
|
||||
--------------------------------------------------------------------------------
|
||||
root x 0 0 root /root /bin/bash
|
||||
|
@ -1736,12 +1736,13 @@ xx: 13
|
||||
xx: 14
|
||||
xx: 15
|
||||
--------------------------------------------------------------------------------
|
||||
[CMD] qseawk -m 500000 --newline=on -d- -vdatafile=lang-035.dat1 -vgroupname=lang-035 -f lang-035.awk lang-035.dat2 </dev/stdin 2>&1
|
||||
[CMD] qseawk -m 500000 --newline=on -d- -vdatadir=/home/hyung-hwan/nfs.exports/workspace/qse/x86_64/linux-wchar-debug/../../src/regress/awk -vdatafile=lang-035.dat1 -vgroupname=lang-035 -f lang-035.awk lang-035.dat2 </dev/stdin 2>&1
|
||||
--------------------------------------------------------------------------------
|
||||
BEGIN {
|
||||
max_cid_vars = 100;
|
||||
datapath = ((datadir "/") datafile);
|
||||
first = 1;
|
||||
while (((getline x < datafile) > 0))
|
||||
while (((getline x < datapath) > 0))
|
||||
{
|
||||
if (first)
|
||||
{
|
||||
@ -1815,6 +1816,7 @@ lease 20.1.20.57 {
|
||||
next binding state free;
|
||||
hardware ethernet 00:13:5e:50:23:6b;
|
||||
info awk.groupname "lang-035";
|
||||
info awk.voice-no-0 "68599021";
|
||||
option agent.circuit-id "BLM1500_AR3_ILAB ONT/9/1/1 /0.0";
|
||||
option agent.unknown-9 0:0:0:c1:8:45:52:49:43:53:53:4f:4e;
|
||||
}
|
||||
@ -1826,6 +1828,7 @@ lease 20.1.20.54 {
|
||||
next binding state free;
|
||||
hardware ethernet 00:13:5e:50:25:aa;
|
||||
info awk.groupname "lang-035";
|
||||
info awk.voice-no-0 "68599011";
|
||||
option agent.circuit-id "BLM1500_AR3_ILAB ONT/9/1/2 /0.0";
|
||||
option agent.unknown-9 0:0:0:c1:8:45:52:49:43:53:53:4f:4e;
|
||||
}
|
||||
@ -1837,6 +1840,7 @@ lease 20.1.20.55 {
|
||||
next binding state free;
|
||||
hardware ethernet 00:13:5e:50:20:af;
|
||||
info awk.groupname "lang-035";
|
||||
info awk.voice-no-0 "68599012";
|
||||
option agent.circuit-id "BLM1500_AR3_ILAB ONT/9/2/1 /0.0";
|
||||
option agent.unknown-9 0:0:0:c1:8:45:52:49:43:53:53:4f:4e;
|
||||
}
|
||||
@ -1848,6 +1852,7 @@ lease 20.1.20.56 {
|
||||
next binding state free;
|
||||
hardware ethernet 00:13:5e:50:20:29;
|
||||
info awk.groupname "lang-035";
|
||||
info awk.voice-no-0 "68599022";
|
||||
option agent.circuit-id "BLM1500_AR3_ILAB ONT/9/2/2 /0.0";
|
||||
option agent.unknown-9 0:0:0:c1:8:45:52:49:43:53:53:4f:4e;
|
||||
}
|
||||
@ -1900,6 +1905,8 @@ lease 10.218.255.55 {
|
||||
hardware ethernet 00:1b:5b:9c:90:00;
|
||||
info awk.groupname "lang-035";
|
||||
uid "\001\000\033[\234\220\000";
|
||||
info awk.voice-no-0 "68599019";
|
||||
info awk.voice-no-1 "68599014";
|
||||
option agent.circuit-id "AR_Remote atm 1/1/03/12:2.100";
|
||||
option agent.remote-id "22M-fast";
|
||||
}
|
||||
@ -1942,6 +1949,7 @@ lease 10.218.255.66 {
|
||||
hardware ethernet 00:1a:04:f9:e2:90;
|
||||
info awk.groupname "lang-035";
|
||||
uid "\001\000\032\004\371\342\220";
|
||||
info awk.voice-no-0 "68599018";
|
||||
option agent.circuit-id "AR_Remote atm 1/1/03/02:2.100";
|
||||
option agent.remote-id "3play";
|
||||
}
|
||||
@ -1954,6 +1962,8 @@ lease 10.218.255.60 {
|
||||
hardware ethernet 00:1e:c7:fb:29:1d;
|
||||
info awk.groupname "lang-035";
|
||||
uid "\001\000\036\307\373)\035";
|
||||
info awk.voice-no-0 "68599017";
|
||||
info awk.voice-no-1 "68599013";
|
||||
option agent.circuit-id "AL_AM3_LAB atm 1/1/01/01:2.100";
|
||||
option agent.remote-id "Testing DHCP";
|
||||
}
|
||||
@ -2336,6 +2346,21 @@ nan
|
||||
8103.08
|
||||
3
|
||||
--------------------------------------------------------------------------------
|
||||
[CMD] qseawk -m 500000 --newline=on -d- -vdatadir=/home/hyung-hwan/nfs.exports/workspace/qse/x86_64/linux-wchar-debug/../../src/regress/awk -vdatafile=lang-046.dat1 -f lang-046.awk lang-046.dat2 </dev/stdin 2>&1
|
||||
--------------------------------------------------------------------------------
|
||||
1
|
||||
|
||||
((getline < ((datadir "/") datafile)) >= 0)
|
||||
|
||||
2 AAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
1 AAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
2 BBBBBBBBBBBBBBBBBBBBBBBBB
|
||||
1 BBBBBBBBBBBBBBBBBBBBBBBBB
|
||||
2 CCCCCCCCCCCCCCCCCCCCCCCCC
|
||||
1 CCCCCCCCCCCCCCCCCCCCCCCCC
|
||||
2 DDDDDDDDDDDDDDDDDDDDDDDDD
|
||||
1 DDDDDDDDDDDDDDDDDDDDDDDDD
|
||||
--------------------------------------------------------------------------------
|
||||
[CMD] qseawk -m 500000 --newline=on -F: -f columnate.awk passwd.dat </dev/stdin 2>&1
|
||||
--------------------------------------------------------------------------------
|
||||
root x 0 0 root /root /bin/bash
|
||||
|
@ -161,7 +161,7 @@ PROGS="
|
||||
lang-032.awk!!!--newline=on -d-
|
||||
lang-033.awk!!!--newline=on -d-
|
||||
lang-034.awk!!!--newline=on --rwpipe=on -d-
|
||||
lang-035.awk!lang-035.dat2!!--newline=on -d- -vdatafile=lang-035.dat1 -vgroupname=lang-035
|
||||
lang-035.awk!lang-035.dat2!!--newline=on -d- -vdatadir=@abs_srcdir@ -vdatafile=lang-035.dat1 -vgroupname=lang-035
|
||||
lang-036.awk!lang-036.dat!!--newline=on -d-
|
||||
lang-037.awk!lang-037.dat!!--newline=on -d-
|
||||
lang-038.awk!!!--newline=on -d-
|
||||
@ -172,6 +172,7 @@ PROGS="
|
||||
lang-043.awk!lang-043.dat!!--newline=on -d-
|
||||
lang-044.awk!lang-044.dat!!--newline=on -d-
|
||||
lang-045.awk!!!--newline=on -d-
|
||||
lang-046.awk!lang-046.dat2!!--newline=on -d- -vdatadir=@abs_srcdir@ -vdatafile=lang-046.dat1
|
||||
|
||||
columnate.awk!passwd.dat!!--newline=on -F:
|
||||
levenshtein-utests.awk!!!--newline=on --include=on
|
||||
|
Loading…
Reference in New Issue
Block a user