forked from Nevensky/SublimeFortran
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlinter.py
More file actions
101 lines (87 loc) · 4.08 KB
/
linter.py
File metadata and controls
101 lines (87 loc) · 4.08 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# 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."""
cmd = 'gfortran -cpp -fsyntax-only -Wall'
multiline = True
# Migrated this upward to keep things neat
on_stderr = True
tempfile_suffix = "f"
# Adding defaults:selector arg because this is required by SublimeLinter as of July 2019
defaults = {
'selector': 'source.fixedform-fortran'
}
# Commenting out args that are no longer used by SublimeLinter as of July 2019
# executable = None
# version_args = '--version'
# version_re = r'(?P<version>\d+\.\d+\.\d+)'
# version_requirement = '>= 4.0'
# Split this into two paths for Windows systems and otherwise
if (sys.platform == 'win32'):
# This Regex block is copied from Kailang's Comment in Issue #28
regex = (
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>.*$)'
)
else:
# This Regex block is retained from the previous commit
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>.*$)'
)
class GfortranModern(Linter):
"""Provides an interface to gfortran."""
cmd = 'gfortran -cpp -fsyntax-only -Wall'
multiline = True
# Migrated this upward to keep things neat
tempfile_suffix = "f90"
on_stderr = True
# Adding defaults:selector arg because this is required by SublimeLinter as of July 2019
defaults = {
'selector': 'source.modern-fortran'
}
# Commenting out args that are no longer used by SublimeLinter as of July 2019
#executable = None
#version_args = '--version'
#version_re = r'(?P<version>\d+\.\d+\.\d+)'
#version_requirement = '>= 4.0'
# Split this into two paths for Windows systems and otherwise
if (sys.platform == 'win32'):
# This Regex block is copied from Kailang's Comment in Issue #28
regex = (
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>.*$)'
)
else:
# This Regex block is retained from the previous commit
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>.*$)'
)