Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1 new exercise: protein-translation #125

Merged
merged 15 commits into from Apr 20, 2024

Conversation

kapitaali
Copy link
Contributor

Adding 1 new exercise to COBOL track: protein-translation

Based on last pull request attempt, all GOBACKs have been removed from code.

Copy link

Hello. Thanks for opening a PR on Exercism 🙂

We ask that all changes to Exercism are discussed on our Community Forum before being opened on GitHub. To enforce this, we automatically close all PRs that are submitted. That doesn't mean your PR is rejected but that we want the initial discussion about it to happen on our forum where a wide range of key contributors across the Exercism ecosystem can weigh in.

You can use this link to copy this into a new topic on the forum. If we decide the PR is appropriate, we'll reopen it and continue with it, so please don't delete your local branch.

If you're interested in learning more about this auto-responder, please read this blog post.


Note: If this PR has been pre-approved, please link back to this PR on the forum thread and a maintainer or staff member will reopen it.

@github-actions github-actions bot closed this Apr 16, 2024
@kapitaali
Copy link
Contributor Author

Forgot config.json once again, but it has been fixed in my branch.

@axtens axtens reopened this Apr 16, 2024
@axtens
Copy link
Member

axtens commented Apr 17, 2024

I've sent a pile of comments via the forum. See https://forum.exercism.org/t/requirements-for-cut-and-proof-ci-cob-files/10818

Copy link
Member

@kotp kotp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The suggested changes are to make lines consistent throughout.

@axtens
Copy link
Member

axtens commented Apr 18, 2024

@ErikSchierboom still have the appveyor issue COBOL / Test (Windows) / ci (pull_request). A separate issue in COBOL / Test / ci (pull_request)

@axtens
Copy link
Member

axtens commented Apr 18, 2024

We could stand to remove some of the DISPLAY statements in the various proof.ci.cob files as they clutter up the test runs

@axtens
Copy link
Member

axtens commented Apr 18, 2024

@kapitaali tests are failing ... but you knew that

@ErikSchierboom
Copy link
Member

Checking protein-translation practice exercise...
Cobolcheck not found, try to fetch it.
CobolCheck: INFO 2024-04-18T03:35:18.670116Z INF001: Attempting to load config from config.properties.
CobolCheck: INFO 2024-04-18T03:35:18.670267Z INF002: Loaded config successfully from config.properties.
CobolCheck: INFO 2024-04-18T03:35:18.670289Z INF003: Cobol-Check starting
CobolCheck: INFO 2024-04-18T03:35:18.670298Z INF005: Log level is INFO.
CobolCheck: INFO 2024-04-18T03:35:18.670306Z INF006: Configuration settings: production.
CobolCheck: INFO 2024-04-18T03:35:18.670637Z INF014: Error log for the test suite parser is set to: /home/runner/work/cobol/cobol/exercises/practice/protein-translation/ParserErrorLog.txt.
CobolCheck: INFO 2024-04-18T03:35:18.670897Z INF013: Output for generated COBOL test program is set to: /home/runner/work/cobol/cobol/exercises/practice/protein-translation/test.cob.
CobolCheck: INFO 2024-04-18T03:35:18.678179Z INF012: Successfully generated COBOL test program for src/protein-translation.
CobolCheck: INFO 2024-04-18T03:35:18.678224Z INF004: Cobol-Check terminating: 0
COMPILE AND RUN TEST
test.cob: in paragraph 'UT-AFTER-EACH':
test.cob:791: error: syntax error, unexpected PERFORM
protein-translation: proof solution did not pass the tests

That makes it appear like there is a syntax error somewhere in protein-translation.

@ErikSchierboom still have the appveyor issue COBOL / Test (Windows) / ci (pull_request)

Feel free to try and fix that, I don't have much time for that.

@axtens
Copy link
Member

axtens commented Apr 18, 2024

Feel free to try and fix that, I don't have much time for that.

Righto. I did get feedback from @GitMensch about that. See #126 (comment) but I'll see what I can do about it in the meantime

@axtens
Copy link
Member

axtens commented Apr 18, 2024

The compiler error is being caused by cobolcheck not properly parsing

AFTER-EACH
	MOVE SPACES TO WS-PROTEIN
END-AFTER

therefore, remove that from the CUT file and explicitly INITIALIZE WS-PROTEIN at the top of the relevant paragraphs.

@axtens
Copy link
Member

axtens commented Apr 18, 2024

This passes all the tests.

       IDENTIFICATION DIVISION.
       PROGRAM-ID. PROTEIN-TRANSLATION.
       AUTHOR. kapitaali.
       ENVIRONMENT DIVISION.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 WS-INPUT                  PIC X(60).
       01 WS-PROTEIN                PIC X(120).
       01 WS-ERROR                  PIC X(60). 
       01 WS-CODON                  PIC XXX.   
       01 WS-AMINOACID              PIC X(14).
       01 SLICES.
         03 SLICE PIC XXX OCCURS 20 TIMES 
            INDEXED BY SLICED.

       PROCEDURE DIVISION.
       TRANSLATE-CODON.
           INITIALIZE WS-PROTEIN WS-ERROR WS-CODON WS-AMINOACID.
           MOVE WS-INPUT TO SLICES.
           SET SLICED TO 1.
           PERFORM WITH TEST BEFORE UNTIL SLICE(SLICED) = SPACE
               MOVE SLICE(SLICED) TO WS-CODON
               PERFORM CHECK-CODON
               SET SLICED UP BY  1
           END-PERFORM.
           IF WS-AMINOACID = "ERROR" 
             MOVE "Invalid codon" TO WS-ERROR
           ELSE 
             MOVE WS-AMINOACID TO WS-PROTEIN.
           EXIT PARAGRAPH.
           
       CHECK-CODON.
           MOVE SPACES TO WS-AMINOACID.
           EVALUATE WS-CODON 
              WHEN SPACE MOVE SPACE TO WS-AMINOACID
              WHEN "AUG" MOVE "Methionine" TO WS-AMINOACID
              WHEN "UUU" MOVE "Phenylalanine" TO WS-AMINOACID
              WHEN "UUC" MOVE "Phenylalanine" TO WS-AMINOACID
              WHEN "UUA" MOVE "Leucine" TO WS-AMINOACID
              WHEN "UUG" MOVE "Leucine" TO WS-AMINOACID
              WHEN "UCU" MOVE "Serine" TO WS-AMINOACID
              WHEN "UCC" MOVE "Serine" TO WS-AMINOACID
              WHEN "UCA" MOVE "Serine" TO WS-AMINOACID
              WHEN "UCG" MOVE "Serine" TO WS-AMINOACID
              WHEN "UAU" MOVE "Tyrosine" TO WS-AMINOACID
              WHEN "UAC" MOVE "Tyrosine" TO WS-AMINOACID
              WHEN "UGU" MOVE "Cysteine" TO WS-AMINOACID
              WHEN "UGC" MOVE "Cysteine" TO WS-AMINOACID
              WHEN "UGG" MOVE "Tryptophan" TO WS-AMINOACID
              WHEN "UAA" MOVE "STOP" TO WS-AMINOACID
              WHEN "UAG" MOVE "STOP" TO WS-AMINOACID
              WHEN "UGA" MOVE "STOP" TO WS-AMINOACID
              WHEN OTHER MOVE "ERROR" TO WS-AMINOACID
           END-EVALUATE.
           EXIT PARAGRAPH.

       TRANSLATE-RNA.
           INITIALIZE WS-PROTEIN WS-ERROR WS-CODON WS-AMINOACID.
           MOVE WS-INPUT TO SLICES.
           SET SLICED TO 1.
           PERFORM WITH TEST AFTER UNTIL SLICE(SLICED) = SPACE
               MOVE SLICE(SLICED) TO WS-CODON
               PERFORM CHECK-CODON
               IF WS-AMINOACID = "STOP"
                 EXIT PERFORM
               END-IF
               IF WS-AMINOACID = "ERROR"
                 MOVE ",ERROR" TO WS-PROTEIN
                 EXIT PERFORM
               END-IF
               STRING WS-PROTEIN DELIMITED BY SPACE 
                 "," DELIMITED BY SIZE
                 WS-AMINOACID DELIMITED BY SPACE 
                 INTO WS-PROTEIN
               END-STRING
               SET SLICED UP BY 1
           END-PERFORM.
           MOVE WS-PROTEIN(2:) TO WS-PROTEIN.
           IF WS-PROTEIN = "ERROR"
             MOVE "Invalid codon" TO WS-ERROR.
           EXIT PARAGRAPH.

@GitMensch
Copy link

If this is also about good COBOL, I'd recommend to drop the EXIT PARAGRAPH - that is seldom used and at the end of the paragraph makes no sense at all.

The complete "fall through" would commonly be seen as bad style. It may should be adjusted to instead of

       TRANSLATE-CODON.
           INITIALIZE WS-PROTEIN WS-ERROR WS-CODON WS-AMINOACID.
           MOVE WS-INPUT TO SLICES.
           SET SLICED TO 1.
           PERFORM WITH TEST BEFORE UNTIL SLICE(SLICED) = SPACE
               MOVE SLICE(SLICED) TO WS-CODON
               PERFORM CHECK-CODON
               SET SLICED UP BY  1
           END-PERFORM.
           IF WS-AMINOACID = "ERROR" 
             MOVE "Invalid codon" TO WS-ERROR
           ELSE 
             MOVE WS-AMINOACID TO WS-PROTEIN.
           EXIT PARAGRAPH.

be:

       TRANSLATE-MAIN.
           INITIALIZE WS-PROTEIN WS-ERROR WS-CODON WS-AMINOACID.
           MOVE WS-INPUT TO SLICES.

           PERFORM TRANSLATE-CODON.
           IF WS-AMINOACID = "ERROR" 
             MOVE "Invalid codon" TO WS-ERROR
             GOBACK.

           MOVE WS-AMINOACID TO WS-PROTEIN.
           PERFORM TRANSLATE-RNA.

           GOBACK.

       TRANSLATE-CODON.
           SET SLICED TO 1.
           PERFORM WITH TEST BEFORE UNTIL SLICE(SLICED) = SPACE
               MOVE SLICE(SLICED) TO WS-CODON
               PERFORM CHECK-CODON
               SET SLICED UP BY  1
           END-PERFORM.

@kapitaali
Copy link
Contributor Author

kapitaali commented Apr 18, 2024

If this is also about good COBOL, I'd recommend to drop the EXIT PARAGRAPH - that is seldom used and at the end of the paragraph makes no sense at all.

it wasn't about good COBOL last time I submitted exercises, the only requirement was that the code passes the tests

GOBACKs supposedly messed up something with testing, so I removed them and used EXIT PARAGRAPH

for good COBOL I would appreciate a style guide

@ErikSchierboom
Copy link
Member

it wasn't about good COBOL last time I submitted exercises, the only requirement was that the code passes the tests

That is still 100% the case.

@GitMensch
Copy link

GitMensch commented Apr 18, 2024

GOBACKs supposedly messed up something with testing, so I removed them and used EXIT PARAGRAPH

GOBACK gets you to the caller (which may be the operating system), you'd only use one if you don't want to "fall out of the program", either in the current fall-through state at the very end, or with a "main" paragraph PERFORMing the other paragraphs at its end, similar as in your example.

As noted: EXIT PARAGRAPH in this code doesn't do anything here, because it gets you directly before the next paragraph - which is the exact place where this statement is.

The rest is a style question and in COBOL those are commonly set fixed in the team/working place (you will find a bunch of those heavily disagreeing; and there may be one where the fall-through is preferred [I've so far just met styles where this was allowed within sections, but not for the whole program]).

@axtens
Copy link
Member

axtens commented Apr 18, 2024

We've found that GOBACK and STOP RUN confuse COBOLCHECK

@GitMensch
Copy link

I'm not sure what you reference with COBOLCHECK, but it seems that part is buggy and may should be improved?

@axtens
Copy link
Member

axtens commented Apr 18, 2024

FYI https://openmainframeproject.org/projects/cobol-check/
github: https://github.com/openmainframeproject/cobol-check/

I'm sure the author would appreciate help improving the tool

@axtens
Copy link
Member

axtens commented Apr 19, 2024

As asked in the forum, How do I rebase #125 so that it uses the new setup? I thought this was what was needed

bugmagnet@bugmagnet-wasta:~/Projects/Everything_Exercism/exercism-tracks/cobol$ git pull upstream main
remote: Enumerating objects: 1, done.
remote: Counting objects: 100% (1/1), done.
remote: Total 1 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (1/1), 927 bytes | 927.00 KiB/s, done.
From https://github.com/exercism/cobol
 * branch            main       -> FETCH_HEAD
   be1cc08..40ed166  main       -> upstream/main
Successfully rebased and updated refs/heads/protein-translation.

ErikSchierboom and others added 6 commits April 19, 2024 22:24
* Add file patterns

* Update files keys
* Pre-fetch cobolcheck

* Use home dir

* Fetch cobolcheck on windows

* Allow for pre-installed cobolcheck
* from appveyor to sourceforge

* different server

* 7z

* 7z

* yaml issue fixed

* slashes

* 7z oddities

* directories

* $HOME ?

* atbash tweak

* cache management fix

* commented out extraneous DISPLAY in proof.ci.cob files

* eol issue

* line ends fixed

* strangenesses

* SPACE instead of "" in CUT files

* Trim additional line

* Debug

* Try simplify environment variables

* More debugging

* More tweaking

* Fix path

* Fix path

* Fix path

* Fix env

* Streamline

* eof is lf

* acronym

* acronym

* sqrt

* Fix paths

* Fix cache path

---------

Co-authored-by: Erik Schierboom <erik_schierboom@hotmail.com>
* Try fix caching

* Try fix cache path

* Try include cobolcheck

* Try include cobolcheck

* Use home dir

* Use home dir
function all intrinsic on its own line
* Try install

* CONCAT -> CONCATENATE

* CONCATENATE is two-fer

---------

Co-authored-by: Bruce Axtens <bruce.axtens@gmail.com>
@axtens
Copy link
Member

axtens commented Apr 19, 2024

@kotp all the CI passes. Lots of hard work done by @ErikSchierboom

@axtens
Copy link
Member

axtens commented Apr 19, 2024

@ErikSchierboom why can't I merge this?

@ErikSchierboom
Copy link
Member

A maintainer has to approve it first

@axtens axtens self-requested a review April 20, 2024 11:24
@axtens axtens merged commit 835af7f into exercism:main Apr 20, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants