summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas Kolstad <lkolstad@uw.edu>2017-03-25 16:02:59 -0700
committerLucas Kolstad <lkolstad@uw.edu>2017-03-25 16:36:17 -0700
commitd84d91ff35cf2852556c10a6bed6c3979348c507 (patch)
tree70aa97b50fb08ac4084fbd3c9bd7dac9de54f2e9
parent822b19ac8376677d73c4df5ce80ed708a1cabd8b (diff)
downloadale-d84d91ff35cf2852556c10a6bed6c3979348c507.zip
Add support for ASM files using GCC
-rw-r--r--.gitignore1
-rw-r--r--README.md1
-rw-r--r--ale_linters/asm/gcc.vim44
-rw-r--r--doc/ale.txt12
-rw-r--r--test/handler/test_asm_handler.vader32
5 files changed, 90 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 3be1b022..30ab9ad6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,4 @@
/doc/tags
.*
*.obj
+tags
diff --git a/README.md b/README.md
index baefd426..80429cfa 100644
--- a/README.md
+++ b/README.md
@@ -52,6 +52,7 @@ name. That seems to be the fairest way to arrange this table.
| Language | Tools |
| -------- | ----- |
+| ASM | [gcc](https://gcc.gnu.org) |
| Ansible | [ansible-lint](https://github.com/willthames/ansible-lint) |
| AsciiDoc | [proselint](http://proselint.com/)|
| Bash | [-n flag](https://www.gnu.org/software/bash/manual/bash.html#index-set), [shellcheck](https://www.shellcheck.net/) |
diff --git a/ale_linters/asm/gcc.vim b/ale_linters/asm/gcc.vim
new file mode 100644
index 00000000..cbc61ed7
--- /dev/null
+++ b/ale_linters/asm/gcc.vim
@@ -0,0 +1,44 @@
+" Author: Lucas Kolstad <lkolstad@uw.edu>
+" Description: gcc linter for asm files
+
+let g:ale_asm_gcc_options =
+\ get(g:, 'ale_asm_gcc_options', '-Wall')
+
+function! ale_linters#asm#gcc#GetCommand(buffer) abort
+ return 'gcc -x assembler -fsyntax-only '
+ \ . '-iquote ' . fnameescape(fnamemodify(bufname(a:buffer), ':p:h'))
+ \ . ' ' . g:ale_asm_gcc_options . ' -'
+endfunction
+
+function! ale_linters#asm#gcc#Handle(buffer, lines) abort
+ let l:pattern = '^.\+:\(\d\+\): \([^:]\+\): \(.\+\)$'
+ let l:output = []
+
+ for l:line in a:lines
+ let l:match = matchlist(l:line, l:pattern)
+
+ if len(l:match) == 0
+ continue
+ endif
+
+ call add(l:output, {
+ \ 'bufnr': a:buffer,
+ \ 'lnum': l:match[1] + 0,
+ \ 'vcol': 0,
+ \ 'col': 0,
+ \ 'text': l:match[3],
+ \ 'type': l:match[2] =~? 'error' ? 'E' : 'W',
+ \ 'nr': -1,
+ \})
+ endfor
+
+ return l:output
+endfunction
+
+call ale#linter#Define('asm', {
+\ 'name': 'gcc',
+\ 'output_stream': 'stderr',
+\ 'executable': 'gcc',
+\ 'command_callback': 'ale_linters#asm#gcc#GetCommand',
+\ 'callback': 'ale_linters#asm#gcc#Handle',
+\})
diff --git a/doc/ale.txt b/doc/ale.txt
index a5630977..fb71de4e 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -43,6 +43,7 @@ CONTENTS *ale-contents*
4.31. yamllint........................|ale-linter-options-yamllint|
4.32. cmakelint.......................|ale-linter-options-cmakelint|
4.33. perl-perl.......................|ale-linter-options-perl-perl|
+ 4.34. asm-gcc.........................|ale-linter-options-asm-gcc|
5. Linter Integration Notes.............|ale-linter-integration|
5.1. merlin..........................|ale-linter-integration-ocaml-merlin|
5.2. rust.............................|ale-integration-rust|
@@ -74,6 +75,7 @@ ALE supports the following key features:
The following languages and tools are supported.
+* ASM: 'gcc'
* Ansible: 'ansible-lint'
* Asciidoc: 'proselint'
* Bash: 'shell' (-n flag), 'shellcheck'
@@ -1120,6 +1122,16 @@ g:ale_perl_perl_options *g:ale_perl_perl_options*
This variable can be changed to alter the command-line arguments to the perl
invocation.
+-------------------------------------------------------------------------------
+4.34. asm-gcc *ale-linter-options-asm-gcc*
+
+g:ale_asm_gcc_options *g:ale_asm_gcc_options*
+
+ Type: |String|
+ Default: `'-Wall'`
+
+ This variable can be set to pass additional options to gcc.
+
===============================================================================
5. Linter Integration Notes *ale-linter-integration*
diff --git a/test/handler/test_asm_handler.vader b/test/handler/test_asm_handler.vader
new file mode 100644
index 00000000..7cee7783
--- /dev/null
+++ b/test/handler/test_asm_handler.vader
@@ -0,0 +1,32 @@
+Execute(The asm GCC handler should parse lines from GCC 6.3.1 correctly):
+ runtime ale_linters/asm/gcc.vim
+
+ AssertEqual
+ \ [
+ \ {
+ \ 'bufnr': 357,
+ \ 'lnum': 38,
+ \ 'vcol': 0,
+ \ 'col': 0,
+ \ 'text': "too many memory references for `mov'",
+ \ 'type': 'E',
+ \ 'nr': -1,
+ \ },
+ \ {
+ \ 'bufnr': 357,
+ \ 'lnum': 42,
+ \ 'vcol': 0,
+ \ 'col': 0,
+ \ 'text': "incorrect register `%ax' used with `l' suffix",
+ \ 'type': 'E',
+ \ 'nr': -1,
+ \ },
+ \ ],
+ \ ale_linters#asm#gcc#Handle(357, [
+ \ "{standard input}: Assembler messages:",
+ \ "{standard_input}:38: Error: too many memory references for `mov'",
+ \ "{standard input}:42: Error: incorrect register `%ax' used with `l' suffix",
+ \ ])
+
+After:
+ call ale#linter#Reset()