From be8a06aff180c10900dc0faf3df119f2e40d0b7e Mon Sep 17 00:00:00 2001 From: Pairi Daiza Date: Mon, 8 Nov 2021 23:03:33 +0100 Subject: [PATCH 1/2] +add: A Fortran Lexer test file --- .../styleLexFortan/Fortran_Control.f90 | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 test/test_files/StyleLexers/styleLexFortan/Fortran_Control.f90 diff --git a/test/test_files/StyleLexers/styleLexFortan/Fortran_Control.f90 b/test/test_files/StyleLexers/styleLexFortan/Fortran_Control.f90 new file mode 100644 index 000000000..a91615985 --- /dev/null +++ b/test/test_files/StyleLexers/styleLexFortan/Fortran_Control.f90 @@ -0,0 +1,49 @@ +! An example of reading a simple control with labels. +! +! Jason Blevins +! Durham, May 6, 2008 + +program control_file + implicit none + + ! Input related variables + character(len=100) :: buffer, label + integer :: pos + integer, parameter :: fh = 15 + integer :: ios = 0 + integer :: line = 0 + + ! Control file variables + real :: pi + integer, dimension(5) :: vector + + open(fh, file='control_file.txt') + + ! ios is negative if an end of record condition is encountered or if + ! an endfile condition was detected. It is positive if an error was + ! detected. ios is zero otherwise. + + do while (ios == 0) + read(fh, '(A)', iostat=ios) buffer + if (ios == 0) then + line = line + 1 + + ! Find the first instance of whitespace. Split label and data. + pos = scan(buffer, ' ') + label = buffer(1:pos) + buffer = buffer(pos+1:) + + select case (label) + case ('pi') + read(buffer, *, iostat=ios) pi + print *, 'Read pi: ', pi + case ('vector') + read(buffer, *, iostat=ios) vector + print *, 'Read vector: ', vector + case default + print *, 'Skipping invalid label at line', line + end select + end if + end do + +end program control_file From 65a298422e71ae3fe061ccfdd10e006e87ad31cd Mon Sep 17 00:00:00 2001 From: Pairi Daiza Date: Mon, 8 Nov 2021 23:24:50 +0100 Subject: [PATCH 2/2] - fix correction of typo --- .../{styleLexFortan => styleLexFortran}/Fortran_Control.f90 | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/test_files/StyleLexers/{styleLexFortan => styleLexFortran}/Fortran_Control.f90 (100%) diff --git a/test/test_files/StyleLexers/styleLexFortan/Fortran_Control.f90 b/test/test_files/StyleLexers/styleLexFortran/Fortran_Control.f90 similarity index 100% rename from test/test_files/StyleLexers/styleLexFortan/Fortran_Control.f90 rename to test/test_files/StyleLexers/styleLexFortran/Fortran_Control.f90