grammars-v4 icon indicating copy to clipboard operation
grammars-v4 copied to clipboard

Error while parsing valid Fortran90 program containing ";" using grammars

Open akoerner opened this issue 1 year ago • 0 comments

Given the following Fortran90 program which can be compiled with gfortran for example:

program Hello
  logical            :: found_cellarea, found_tocell
  found_cellarea = .FALSE.    ; found_tocell = .FALSE.
  write(*,*) 'Hello'
end program Hello

The following parsing error is produced when using the provided grammars:

line 4:30 token recognition error at: ';'

The lexer grammar (fortran/fortran90/Fortran90Lexer.g4) does not contain a semicolon definition. The parser grammar (fortran/fortran90/Fortran90Parser.g4) does not contain an associated semicolon rule.

In Fortran90 the semicolon ';' was added to allow separate but related statements to be placed on the same line.

Better information on this can be found here: https://www.nsc.liu.se/~boein/f77to90/a3.html Excerpt from that site:

"...several statements can be given on the same line if using the semicolon ; as a separator..."

akoerner avatar Sep 13 '23 19:09 akoerner