Merge pull request #364 from Neppord/main

Added GnuCobol support
This commit is contained in:
Emily Bache 2022-10-05 08:15:05 +02:00 committed by GitHub
commit a7cebcebed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 122 additions and 0 deletions

1
COBOL/Gnu/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.so

38
COBOL/Gnu/Add.cbl Normal file
View File

@ -0,0 +1,38 @@
program-id. Add as "Add".
environment division.
input-output section.
file-control.
select in-items assign 'in-items'.
data division.
file section.
fd in-items.
01 item.
02 sell-in pic s9(2).
02 quality pic s9(2).
02 name pic x(50).
working-storage section.
01 accept-item.
02 sell-in pic s9(2).
02 quality pic s9(2).
02 name pic x(50).
procedure division.
open extend in-items.
display "name"
accept name in accept-item.
display "sell-in"
accept sell-in in accept-item.
display "quality"
accept quality in accept-item.
move accept-item to item.
write item.
close in-items.
goback.
end program Add.

77
COBOL/Gnu/GildedRose.cbl Normal file
View File

@ -0,0 +1,77 @@
program-id. GildedRose as "GildedRose".
environment division.
input-output section.
file-control.
select in-items assign 'in-items'.
select items assign 'items'.
data division.
file section.
fd in-items.
01 in-item pic x(54).
fd items.
01 item.
02 sell-in pic s9(2).
02 quality pic s9(2).
02 name pic x(50).
working-storage section.
procedure division.
open input in-items output items.
start-lable.
read in-items end go to end-lable.
move in-item to item.
if name not equal "Aged Brie" and name not equal "Backstage passes to a TAFKAL80ETC concert"
if quality > 0
if name not equal to "Sulfuras, Hand of Ragnaros"
compute quality = quality - 1
end-if
end-if
else
if quality < 50
compute quality = quality + 1
if name equals "Backstage passes to a TAFKAL80ETC concert"
if sell-in < 11
if quality < 50
compute quality = quality + 1
end-if
end-if
if sell-in < 6
if quality < 50
compute quality = quality + 1
end-if
end-if
end-if
end-if
end-if
if name not equal "Sulfuras, Hand of Ragnaros"
compute sell-in = sell-in - 1
end-if
if sell-in < 0
if name is not equal to "Aged Brie"
if name is not equal to "Backstage passes to a TAFKAL80ETC concert"
if quality > 0
if name is equal to "Sulfuras, Hand of Ragnaros"
compute quality = quality - 1
end-if
end-if
else
compute quality = quality - quality
end-if
else
if quality < 50
compute quality = quality + 1
end-if
end-if
end-if
write item.
go to start-lable.
end-lable.
close items.
close in-items.
goback.
end program GildedRose.

2
COBOL/Gnu/add.sh Executable file
View File

@ -0,0 +1,2 @@
touch in-items
cobcrun Add

1
COBOL/Gnu/build.sh Executable file
View File

@ -0,0 +1 @@
cobc --free --std=mf -O *.cbl

1
COBOL/Gnu/run.sh Executable file
View File

@ -0,0 +1 @@
cobcrun GildedRose

2
COBOL/Gnu/test.sh Executable file
View File

@ -0,0 +1,2 @@
./build.sh
./run.sh