Well, since I now have the answer to this question, I think I should share it.
Fortran 77, like all other languages โโthat care about columns, is a line-oriented language. This means that your parser must track the EOL and actually use it when parsing.
Another important fact is that in my case itโs not important for me to parse the line numbers that Fortran can put in the early control columns. All I need to know is when he tells me to scan the rest of the line differently.
Given these two things, I could completely handle this problem with the help of the Spirit scroll analyzer. I wrote mine
- skip the whole line if the first (comment) column contains an alphabetic character.
- skip the entire line if there is nothing on it.
- ignore the previous EOL and all up to the fifth column if there is a character in the fifth column. (continuation of the line). This binds it to the previous line.
- skip all non-eol spaces (even spaces in Fortran don't matter. Yes, it's a weird language.)
Here is the code:
skip =
I would advise you not to blindly use this on your own for line-oriented Fortran, since I ignore line numbers, and different compilers have different rules for valid comment and continuation characters.
source share