-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathlinter.py
56 lines (51 loc) · 2.19 KB
/
linter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# linter.py
# Linter for SublimeLinter3, a code checking framework for Sublime Text 3
"""This module exports the Gfortran plugin class."""
# Since SublimeLinter is loaded after SublimeFortran, we need to manually import Linter
import sublime, os, sys
try:
sys.path.append(os.path.join(sublime.packages_path(), 'SublimeLinter'))
from SublimeLinter.lint import Linter
sys.path.remove(os.path.join(sublime.packages_path(), 'SublimeLinter'))
except (ImportError):
print("SublimeFortran: Failed to load SublimeLinter")
class Linter(object):
pass
class GfortranFixedForm(Linter):
"""Provides an interface to gfortran."""
syntax = 'fortranfixedform'
cmd = 'gfortran -cpp -fsyntax-only -Wall'
executable = None
version_args = '--version'
version_re = r'(?P<version>\d+\.\d+\.\d+)'
version_requirement = '>= 4.0'
multiline = True
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|$\r?\n^$\r?\n^.*$\r?\n^\s*\d$\r?\n)'
# Finally we have (Error|Warning): message to the end of the line
r'(?:(?P<error>Error|Fatal\sError)|(?P<warning>Warning)): (?P<message>.*$)'
)
tempfile_suffix = "f"
on_stderr = True
class GfortranModern(Linter):
"""Provides an interface to gfortran."""
syntax = 'fortranmodern'
cmd = 'gfortran -cpp -fsyntax-only -Wall'
executable = None
version_args = '--version'
version_re = r'(?P<version>\d+\.\d+\.\d+)'
version_requirement = '>= 4.0'
multiline = True
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|$\r?\n^$\r?\n^.*$\r?\n^\s*\d$\r?\n)'
# Finally we have (Error|Warning): message to the end of the line
r'(?:(?P<error>Error|Fatal\sError)|(?P<warning>Warning)): (?P<message>.*$)'
)
tempfile_suffix = "f90"
on_stderr = True