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

Preprocessor style comments (lines starting with "//") only seem to work if next character is a space #91

Open
RolfSander opened this issue Dec 14, 2023 · 7 comments
Labels
bug Something isn't working code / structural Related to structural source code updates

Comments

@RolfSander
Copy link
Contributor

Preprocessor style comments (lines starting with "//") only seem to work if the next character is a space. Otherwise, I get the error message:

Extra parameter on command line

This needs to be fixed, probably in scan.l, where COMMENT2 is defined.

@RolfSander RolfSander added the bug Something isn't working label Dec 14, 2023
@RolfSander RolfSander mentioned this issue Dec 20, 2023
Merged
@yantosca
Copy link
Contributor

@RolfSander, is this still an issue or was it addressed in PR #92? Maybe I can take a look if it's still an open issue.

@yantosca yantosca added the code / structural Related to structural source code updates label Jun 14, 2024
@RolfSander
Copy link
Contributor Author

RolfSander commented Jun 14, 2024

The problem still exists :-(

I have created a temporary branch called issue91test with several test
cases in the ci-tests/F90_small_strato directory. The
issue91test_ok*.kpp files work fine, but the issue91test_err*.kpp
files crash. The only difference between them is the location of a
comment that starts with // and has no space afterwards.

Can you reproduce the errors?

@yantosca
Copy link
Contributor

Hi @RolfSander, I am finally back after being away for a bit. Yes, I am able to replicate your results on my end. Also, I modified the ok1 case by adding the same comment after #STOICHMAT ON:

//This is a comment without a space after the two slashes
#MODEL      small_strato
#LANGUAGE   Fortran90
#DOUBLE     ON
#INTEGRATOR rosenbrock
#DRIVER     general
#JACOBIAN   SPARSE_LU_ROW
#HESSIAN    ON
#STOICMAT   ON

//This is a comment without a space after the two slashes

{This is the small_strato example from Chapter 2 of the KPP manual}

and I get this error:

KPP is parsing the equation file.Error :issue91test_ok1.kpp:11: Extra parameter on command line '//This'
Error :issue91test_ok1.kpp:11: Extra parameter on command line 'is'
Error :issue91test_ok1.kpp:11: Extra parameter on command line 'a'
Error :issue91test_ok1.kpp:11: Extra parameter on command line 'comment'
Error :issue91test_ok1.kpp:11: Extra parameter on command line 'without'
Error :issue91test_ok1.kpp:11: Extra parameter on command line 'a'
Error :issue91test_ok1.kpp:11: Extra parameter on command line 'space'
Error :issue91test_ok1.kpp:11: Extra parameter on command line 'after'
Error :issue91test_ok1.kpp:11: Extra parameter on command line 'the'
Error :issue91test_ok1.kpp:11: Extra parameter on command line 'two'
Error :issue91test_ok1.kpp:11: Extra parameter on command line 'slashes'

Then I tried:

//This is a comment without a space after the two slashes
#MODEL      small_strato
#LANGUAGE   Fortran90
#DOUBLE     ON
#INTEGRATOR rosenbrock
#DRIVER     general
#JACOBIAN   SPARSE_LU_ROW
#HESSIAN    ON
#STOICMAT   ON

//This is a comment without a space after the two slashes

// This is a comment with a space after the two slashes

{This is the small_strato example from Chapter 2 of the KPP manual}

and I got the same error. I think it because it is expecting a #COMMAND and not finding one, the parsing gets halted. Where in the parser would we look for this?

@RolfSander
Copy link
Contributor Author

@yantosca, thanks for testing this!

Where in the parser would we look for this?

It is called COMMENT2 in scan.l. I checked the file but couldn't
find any requirement for a space after the //.

@yantosca
Copy link
Contributor

@RolfSander: I took a look at scan.l. As is my understanding (and my understanding of Flex isn't that great), the line:

<COMMENT2>[^\n]*        {
                        } 

should ignore zero or more instances of any character except a newline. I tried a couple of other things but they didn't work. I may give up on this for a bit.

@RolfSander
Copy link
Contributor Author

As we cannot solve this problem, let's change our strategy: It's not a
bug, it's a feature! I suggest we simply adjust our documentation
accordingly:

Comments are either enclosed between the curly braces { and }, or
written in a line starting with two slashes and a space "// ".

Copy link
Contributor

I agree!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working code / structural Related to structural source code updates
Projects
None yet
Development

No branches or pull requests

2 participants