# 'FUNCTION RANDOM()' causes parsing error when parsing AcuCobol source

**URL:** <https://community.sonarsource.com/t/function-random-causes-parsing-error-when-parsing-acucobol-source/88190>\
**Category:** SonarQube Server / Community Build\
**Tags:** parse-error, cobol, sonarqube\
**Created:** [March 28, 2023, 3:48pm UTC](https://community.sonarsource.com/t/function-random-causes-parsing-error-when-parsing-acucobol-source/88190 "2023-03-28T15:48:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jos\_Abrahams](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/jos_abrahams/32/43608_2.png) [@Jos\_Abrahams](https://community.sonarsource.com/u/Jos_Abrahams)\
**Post date:** [March 28, 2023, 3:48pm UTC](https://community.sonarsource.com/t/function-random-causes-parsing-error-when-parsing-acucobol-source/88190/1 "2023-03-28T15:48:52Z")

</div>

We are trying to parse Cobol sources.

Versions used:  
Cobol: AcuCobol version 10.2.1, fixed format  
SonarQube: Enterprise Edition Version 9.6.1 (build 59531)

The ‘FUNCTION RANDOM’ statement below compiles, although it does not comply to the Acucobol spec. It is however used in the reference manual as an example.  
This fact causes developers to use the function in the shown way.

It does not parse, but inserting a ‘0’ between the parenthesis fixes that.

Extract from the parser logfile:

```auto
ERROR: Unable to parse COBOL source file : /build/builds/_NwxSV3v/0/dataserver-utilities/tdeltaplayground/sonar-parse-errors/cobol-src/source/PP0023 at line 11

Original contents starting from line 1 till line 12:
       IDENTIFICATION DIVISION.
       PROGRAM-ID. PP0023.
       WORKING-STORAGE SECTION.
       01 VARIABLE PIC S9V999.
       PROCEDURE DIVISION.
           MOVE FUNCTION RANDOM() TO VARIABLE
           GOBACK.

Preprocessed contents: 
Parse error at line 11:

    1: IDENTIFICATION DIVISION .
    2: PROGRAM-ID . PP0023 .
    3: WORKING-STORAGE SECTION .
    4: 01 VARIABLE PIC S9V999 .
    5: PROCEDURE DIVISION .
   11: MOVE FUNCTION RANDOM ( ) TO VARIABLE
                              ^
   12: GOBACK .
   13: EOF

```

Please have the parser accept this syntax.

---

<div class="post-metadata">

**Author:** ![pynicolas](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/pynicolas/32/675_2.png) [@pynicolas](https://community.sonarsource.com/u/pynicolas)\
**Post date:** [March 30, 2023, 4:07pm UTC](https://community.sonarsource.com/t/function-random-causes-parsing-error-when-parsing-acucobol-source/88190/4 "2023-03-30T16:07:15Z")

</div>

We should fix this parsing error.  
Thank you for the very good analysis!  
Ticket created: [SONARCOBOL-1649](https://sonarsource.atlassian.net/browse/SONARCOBOL-1649)
