Nevensky / SublimeFortran

Fortran syntax highlighting for Sublime Text 3
47 stars 30 forks source link

The gfortran linter is not working? [Win 10] #28

Open 8fdafs2 opened 8 years ago

8fdafs2 commented 8 years ago

The gfortran is already in system path and I also tried putting its path in linter setting file. Either way it's not working.

8fdafs2 commented 8 years ago

I have changed the regex variable in linter.py so it works now.

    regex = (
        # filename:line:col: is common for multiline and single line warnings
        r'.*:(?P<line>\d+):(?P<col>\d+):'
        # Then we either have a space or (a newline, a newline, some source code,
        # a newline, a col number, a newline)
        r'(?:(\s*.*\s*\d+\s*))'
        # Finally we have (Error|Warning): message to the end of the line
        r'(?P<error>(Error|Fatal Error)|(?P<warning>Warning)): (?P<message>.*)'
    )
Kailang commented 8 years ago

I'm using GNU Fortran (GCC) 5.3.0 on Windows 10 as part of MinGW.

I got error messages that SublimeFortran's regex cannot handle. Something like:

c:\users\kailang\appdata\local\temp\SublimeLinter3-Kailang\psddf.f90:285:21:

         last_print = printt(ntime)
                     1
Warning: Possible change of value in conversion from REAL(8) to INTEGER(4) at (1) [-Wconversion]

And @8fdafs2 's regex works, as it correctly extracts some information. As shown here: https://regex101.com/r/xR8gH0/2

But, it incorrectly assigns "Warning" to both P<error> and P<warning>, which let SublimeLinter recognize every message as an error.

The good news is, the 3rd line of original regex can work! So I simply substitute the @8fdafs2's 3rd line with the original one, and it works perfectly.

    regex = (
        # filename:line:col: is common for multiline and single line warnings
        r'.*:(?P<line>\d+):(?P<col>\d+):'
        # Then we either have a space or (a newline, a newline, some source code,
        # a newline, a col number, a newline)
        r'(?:(\s*.*\s*\d+\s*))'
        # Finally we have (Error|Warning): message to the end of the line
        r'(?:(?P<error>Error|Fatal\sError)|(?P<warning>Warning)): (?P<message>.*$)'
    )

As shown here: https://regex101.com/r/xR8gH0/3

Maybe the original regex was written for a different of gfortran.

Thanks, @8fdafs2.