Skip to content

Commit 62b98f3

Browse files
committed
Better pipe assignment tokens, future keywords
1 parent d7c4f48 commit 62b98f3

File tree

20 files changed

+67
-29
lines changed

20 files changed

+67
-29
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* oltp: Option to emulate batch with no wait time
1212
* New more secure syntax for file/pipe open
1313
* Public utility netthroughput.rwl replaces nettest.rwl
14+
* Add case, switch, when as future keywords
1415

1516
## 3.0.2
1617

docs/FILE.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ There are different assignment operators to allow for read, append, etc:
1313
* To open for write, simply assign a string containing the file name to it using := or >=.
1414
* To open for append, use the >>= assignment operator.
1515
* To open for read, use the <= assignment operator.
16-
* To open a pipeline for write, use the \|= operator, the concatenation will be the command to execute.
17-
* To open a pipeline for read, use the =\| operator, the concatenation will be the command to execute.
16+
* To open a pipeline for write, use the >\|= operator, the concatenation will be the command to execute.
17+
* To open a pipeline for read, use the <\|= operator, the concatenation will be the command to execute.
1818

1919
The writeline and printline commands of rwloadsim do not include
2020
advanced output formatting, strings are
@@ -37,7 +37,7 @@ A simple example of reading from a pipeline is:
3737
file id;
3838
string(1000) myid;
3939
40-
id =| "id";
40+
id <|= "id";
4141
readline id,myid;
4242
id := null;
4343
@@ -81,7 +81,7 @@ end loop;
8181
yt := null; # close the file
8282
8383
# use a pipeline to read the file
84-
yt =| "cat numbers.txt";
84+
yt <|= "cat numbers.txt";
8585
8686
for readline yt,a,b loop # similar to read a,b in the shell
8787
printline a,b,sqrt(b);

docs/refman/filestatement.html

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/refman/statement.html

Lines changed: 7 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/man1rwl/filestatement.1rwl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
.SH NAME
33
file, filestatement \- RWP*Load Simulator use of files
44
.SH SYNTAX
5-
identifier ( \fB:=\fR | \fB>=\fR | \fB>>=\fR | \fB<=\fR | \fB|=\fR | \fB=|\fR ) concatenation
5+
identifier ( \fB:=\fR | \fB>=\fR | \fB>>=\fR | \fB<=\fR | \fB>|=\fR | \fB<|=\fR ) concatenation
66
.P
77
identifier
88
.B := null
@@ -63,13 +63,13 @@ v \fB<=\fR e
6363
Open a file for reading.
6464
.RE
6565
.P
66-
v \fB|=\fR e
66+
v \fB>|=\fR e
6767
.RS 4
6868
Open a pipeline for writing; the concatenation will be given to the popen() call with
6969
a second argument of "w".
7070
.RE
7171
.P
72-
v \fB=|\fR e
72+
v \fB<|=\fR e
7373
.RS 4
7474
Open a pipeline for reading; the concatenation will be given to the popen() call with
7575
a second argument of "r".

man/man1rwl/statement.1rwl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ statement ::=
77
simpledeclaration
88
| identifier \fB(\fR [ concatenation { \fB,\fR concatenation } ] \fB)\fR [ atclause ]
99
| identifier ( \fB:=\fR | \fB||=\fR | \fB+=\fR ) concatenation
10-
| identifier ( \fB<=\fR | \fB>=\fR | \fB>>=\fR | \fB|=\fR | \fB=|\fR ) concatenation
10+
| identifier ( \fB<=\fR | \fB>=\fR | \fB>>=\fR | \fB>|=\fR | \fB<|=\fR ) concatenation
1111
| \fBnull\fR [ concatenation ]
1212
| \fBreturn\fR [ concatenation ]
1313
| \fBexit\fR concatenation
@@ -60,7 +60,7 @@ Assignments are not expressions, so you cannot do something like:
6060
.PP
6161
a := b := 0;
6262
.PP
63-
The assignment operators \fB>=\fR, \fB>>=\fR, \fB<=\fR, \fB|=\fR, \fB=|\fR are used
63+
The assignment operators \fB>=\fR, \fB>>=\fR, \fB<=\fR, \fB>|=\fR, \fB<|=\fR are used
6464
with files to respectively open for write, append, read, write to a pipeline or
6565
read from a pipeline.
6666
See filestatement(1rwl) for details.

src/rwl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
*
1414
* History
1515
*
16+
* bengsig 19-sep-2022 - Future keywords
1617
* bengsig 10-aug-2022 - Output userhelp in order from rwl source file
1718
* bengsig 11-jul-2022 - $sessionpool_no_rlb directive
1819
* bengsig 28-jun-2022 - Generate project
@@ -887,6 +888,7 @@ struct rwl_main
887888
#define RWL_P3_GENERATE_OK 0x00200000 // OK to actually generate
888889
#define RWL_P3_GEN_SENSITIVE 0x00400000 // During generation, a sensible keyword was found
889890
#define RWL_P3_SP_NORLB 0x00800000 // $sessionpool_no_rlb:on (which is default)
891+
#define RWL_P3_FUTNOTIDENT 0x01000000 // warn about an identifier becoming a keyword
890892

891893
int userexit; // value for user exit
892894

src/rwldilex.l

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,8 @@
241241
":=" |
242242
">>=" |
243243
"<<=" |
244-
"=|" |
244+
">|=" |
245+
"<|=" |
245246
"+=" |
246247
"sql_id" |
247248
"serverrelease" |

src/rwlerror.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
*
1212
* History
1313
*
14+
* bengsig 19-sep-2022 - Future keywords
1415
* bengsig 15-sep-2022 - New file assignment operators
1516
* bengsig 12-sep-2022 - More options to access function
1617
* bengsig 11-jul-2022 - Correct option error
@@ -1598,3 +1599,9 @@ RWLERROR("closing a file with an operator used for open", RWL_ERROR_WARNING)
15981599
RWLEDESC("You are using one of the operators used to open a file or pipeline to\n"
15991600
"close a file by assigning null to it. You should use the := operator")
16001601

1602+
#define RWL_ERROR_RESERVED_FOR_FUTURE2 293
1603+
RWLERROR("'%s' will be a keyword in a future release", RWL_ERROR_WARNING)
1604+
RWLEDESC("You are using an identifier that in some future release will be a keyword.\n"
1605+
"You should change your code and use a different identifer as it otherwise will"
1606+
"cause a syntax error in the future")
1607+

src/rwllexer.l

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
*
1212
* History
1313
*
14+
* bengsig 19-sep-2022 - Future keywords
1415
* bengsig 15-sep-2022 - New file assignment operators
1516
* bengsig 11-jul-2022 - $sessionpool_no_rlb directive
1617
* bengsig 28-jun-2022 - Generate project
@@ -585,9 +586,9 @@
585586
/*LEXTAG:RWL_T_CONCAT*/
586587
"||" if (!rwm->ifdirbit) return RWL_T_CONCAT;
587588
/*LEXTAG:RWL_T_PIPETO*/
588-
"|=" if (!rwm->ifdirbit) return RWL_T_PIPETO;
589+
">|=" if (!rwm->ifdirbit) return RWL_T_PIPETO;
589590
/*LEXTAG:RWL_T_PIPEFROM*/
590-
"=|" if (!rwm->ifdirbit) return RWL_T_PIPEFROM;
591+
"<|=" if (!rwm->ifdirbit) return RWL_T_PIPEFROM;
591592
/*LEXTAG:RWL_T_APPEND*/
592593
"||=" if (!rwm->ifdirbit) return RWL_T_APPEND;
593594
/*LEXTAG:RWL_T_SERVERRELEASE*/
@@ -643,6 +644,19 @@
643644
if (!rwm->ifdirbit) return RWL_T_ASNPLUS;
644645
}
645646

647+
"when" |
648+
"switch" |
649+
"case" {
650+
bic(rwm->m3flags, RWL_P3_WARNSQLKW);
651+
if (!rwm->ifdirbit)
652+
{
653+
rwm->previnam = rwm->inam;
654+
rwm->inam = rwlstrdup(rwm, (text *)yytext);
655+
bis(rwm->m3flags, RWL_P3_FUTNOTIDENT);
656+
return RWL_T_IDENTIFIER;
657+
}
658+
}
659+
646660
/*LEXTAG:RWL_T_IDENTIFIER*/
647661
[a-zA-Z_][a-zA-Z0-9_]* {
648662
/*

0 commit comments

Comments
 (0)