YAPC::EU 2018 Glasgow Update!
This commit is contained in:
parent
22f33d4004
commit
4e2d22a71d
1170 changed files with 15042 additions and 3047 deletions
|
|
@ -0,0 +1,24 @@
|
|||
\ Rosetta Code Strip Comment
|
||||
|
||||
: LASTCHAR ( addr len -- addr len c) 2DUP + 1- C@ ;
|
||||
|
||||
: COMMENT? ( char -- ? ) S" #;" ROT SCAN NIP ; \ is char '#' or ';'
|
||||
|
||||
: -COMMENT ( addr len -- addr len') \ removes # or ; comments
|
||||
BEGIN
|
||||
LASTCHAR COMMENT? 0=
|
||||
WHILE \ while not a comment char...
|
||||
1- \ reduce length by 1
|
||||
REPEAT
|
||||
1- ; \ remove 1 more (the comment char)
|
||||
|
||||
\ -TRAILING is resident in desktop Forth systems like Swift Forth
|
||||
\ shown here for demonstration
|
||||
: -TRAILING ( adr len -- adr len') \ remove trailing spaces
|
||||
BEGIN
|
||||
LASTCHAR BL =
|
||||
WHILE \ while lastchar = blank char
|
||||
1- \ reduce length by 1
|
||||
REPEAT ;
|
||||
|
||||
: COMMENT-STRIP ( addr len -- addr 'len) -COMMENT -TRAILING ;
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
S" apples, pears # and bananas" COMMENT-STRIP TYPE apples, pears ok
|
||||
S" apples, pears ; and bananas" COMMENT-STRIP TYPE apples, pears ok
|
||||
Loading…
Add table
Add a link
Reference in a new issue