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

In fortran fixed format files, comments beginning with other characters than ! (e.g, c, C etc) are not treated as comments #61

Open
sahashirshendu opened this issue Feb 10, 2022 · 7 comments
Labels
enhancement Improvement to the existing code base help wanted Extra attention is needed

Comments

@sahashirshendu
Copy link

No description provided.

@gzagatti
Copy link

I am having a similar problem. As I am working with LAPACK code, line comments start with *.

It seems like FORTRAN 77 comments are line that start with letter c or an *.

@stadelmanma
Copy link
Owner

Fixed form format isn't perfectly supported. I think some code would need added to the scanner.cc file to detect non-standard comment characters.

@stadelmanma stadelmanma added enhancement Improvement to the existing code base help wanted Extra attention is needed labels Dec 14, 2022
@ZedThree
Copy link
Collaborator

I suspect that fixed form will be fundamentally incompatible with free form in the same parser. Any character in column 1 indicates a comment in fixed form, and I don't think there's any way of passing options into the parser. In the C++ parser, for instance, they've squashed all the different standards into one.

One option is to use something like fixed2free.py to convert the source to free form, and then use tree-sitter.

@stadelmanma
Copy link
Owner

I wonder if we could do Fixed Form Fortran by importing this language into it and customizing the scanner part to deal with columns 1-7? I don’t really know how tree sitter “imports” other languages but you mentioned the CPP parser doing that. I suspect it would be more liberal than an actual fixed form complier but it also wouldn’t require massive code duplication.

@ZedThree
Copy link
Collaborator

I think that would be the most economical way of doing things. Here's the important bits from the C++ parser:

const C = require("tree-sitter-c/grammar")

module.exports = grammar(C, {
  // C++ specific rules
  ...

They then have tree-sitter-c in devDependencies in package.json, so I guess that would require having tree-sitter-fortran on npm?

@stadelmanma
Copy link
Owner

I’d wager we could reference a git repo in the package.json but pushing this to NPM eventually makes sense. Seems the mainline tree-sitter languages all have 0.X tags versus committing to a “stable” 1.X release.

@stadelmanma
Copy link
Owner

Added a repo to catch this work eventually, https://github.com/stadelmanma/tree-sitter-fixed-form-fortran.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement to the existing code base help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants