There was a defect reported for ciforth:
If switched to CASE-INSENSITIVE [THEN] is not recognized in
lower case.
There is nothing in [IF] that suggest it must recognize
lower case [then]. Also the implementation in the standard
doesn't do this.
Now ruv got me. [THEN] is supposedly a standard word.
The implementation in the annex fails this.
That leads to the following using a forward definition.
We are not comparing strings, we look up definitions and
they are subject to case-sensitivity:
\ --------------------------------------------
( [IF] ] [ELSE] [THEN] [DEFINED] [UNDEFINED] ) \ AvdH C6sep20
WANT :F
:F SKIPPING ;
: [IF] 0= IF SKIPPING THEN ; IMMEDIATE ISO
: [ELSE] SKIPPING ; IMMEDIATE ISO
: [THEN] ; IMMEDIATE ISO
:R SKIPPING
1 BEGIN NAME DUP WHILE FOUND
DUP '[IF] = IF DROP 1+ ELSE
DUP '[ELSE] = IF DROP 1- DUP IF 1+ THEN ELSE
'[THEN] = IF 1- THEN THEN THEN
?DUP 0= IF EXIT THEN
REPEAT 2DROP DROP ;
: [UNDEFINED] NAME 2DUP WANTED PRESENT 0= ; IMMEDIATE ISO
: [DEFINED] POSTPONE [UNDEFINED] 0= ; IMMEDIATE ISO
\ --------------------------------------------
"2ROT" [UNDEFINED] [IF]
: 2ROT >R >R 2SWAP R> R> 2SWAP ;
[ELSE]
." NOT NEEDED"
[THEN]
1 2 3 4 5 6 2ROT . . . . . . CR
"1 2 3 4 5 6 2rot . . . . . . CR" 'EVALUATE CATCH ERROR
WANT CASE-INSENSITIVE
1 2 3 4 5 6 2rot . . . . . . CR
The test output:
\ --------------------------------------------
albert@sinas2:~/PROJECT/ciriscv$ lina -a
INCLUDE ifdef.frt
2 1 6 5 4 3
1 2 3 4 5 6 2rot ? ciforth ERROR # 10 : NOT A WORD, NOR A NUMBER OR OTHER DENOTATION
2 1 6 5 4 3
OK
\ --------------------------------------------
Maybe the implementation of 2ROT is wrong, but that is not the point.
Now the question for language lawyers:
Why is this implementation of conditional compilation
not compliant? (It isn't!)
Note as an implementer I'm fully entitled to use ciforth
idiosyncrasies to implement or test.
Groetjes Albert
| Sysop: | Amessyroom |
|---|---|
| Location: | Fayetteville, NC |
| Users: | 76 |
| Nodes: | 6 (0 / 6) |
| Uptime: | 54:25:27 |
| Calls: | 1,265 |
| Calls today: | 1 |
| Files: | 1,362 |
| D/L today: |
3 files (2,684K bytes) |
| Messages: | 285,563 |