Family Day update
This commit is contained in:
parent
aac6731f2c
commit
9ad63ea473
2442 changed files with 39761 additions and 8255 deletions
|
|
@ -0,0 +1,21 @@
|
|||
identification division.
|
||||
program-id. StripComments.
|
||||
|
||||
data division.
|
||||
working-storage section.
|
||||
01 line-text pic x(64).
|
||||
|
||||
procedure division.
|
||||
main.
|
||||
move "apples, pears # and bananas" to line-text
|
||||
perform show-striped-text
|
||||
|
||||
move "apples, pears ; and bananas" to line-text
|
||||
perform show-striped-text
|
||||
|
||||
stop run
|
||||
.
|
||||
show-striped-text.
|
||||
unstring line-text delimited by "#" or ";" into line-text
|
||||
display quote, function trim(line-text), quote
|
||||
.
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
\ Rosetta Code Strip Comment
|
||||
|
||||
: LASTCHAR ( addr len -- addr len c) 2DUP + C@ ;
|
||||
: COMMENT? ( char -- ? ) S" #;" ROT SCAN NIP ; \ test char for "#;"
|
||||
: -LEADING ( addr len -- addr' len') BL SKIP ; \ remove leading space characters
|
||||
|
||||
: -COMMENT ( addr len -- addr len') \ removes # or ; comments
|
||||
1-
|
||||
BEGIN
|
||||
LASTCHAR COMMENT? 0=
|
||||
WHILE \ while not a comment char...
|
||||
1- \ reduce length by 1
|
||||
REPEAT
|
||||
1- ; \ remove 1 more (the comment char)
|
||||
|
||||
: -TRAILING ( adr len -- addr len') \ remove trailing spaces
|
||||
1-
|
||||
BEGIN
|
||||
LASTCHAR BL =
|
||||
WHILE \ while lastchar = blank
|
||||
1- \ reduce length by 1
|
||||
REPEAT
|
||||
1+ ;
|
||||
|
||||
: COMMENT-STRIP ( addr len -- addr 'len) -LEADING -COMMENT -TRAILING ;
|
||||
Loading…
Add table
Add a link
Reference in a new issue