Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | " Vim syntax file |
| 2 | " Language: GNU Assembler |
Bram Moolenaar | 555cdc2 | 2010-01-12 21:31:21 +0100 | [diff] [blame] | 3 | " Maintainer: Erik Wognsen <erik.wognsen@gmail.com> |
| 4 | " Previous maintainer: |
| 5 | " Kevin Dahlhausen <kdahlhaus@yahoo.com> |
Bram Moolenaar | 00a927d | 2010-05-14 23:24:24 +0200 | [diff] [blame] | 6 | " Last Change: 2010 Apr 18 |
| 7 | |
| 8 | " Thanks to Ori Avtalion for feedback on the comment markers! |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 9 | |
| 10 | " For version 5.x: Clear all syntax items |
Bram Moolenaar | 555cdc2 | 2010-01-12 21:31:21 +0100 | [diff] [blame] | 11 | " For version 6.0 and later: Quit when a syntax file was already loaded |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 12 | if version < 600 |
| 13 | syntax clear |
| 14 | elseif exists("b:current_syntax") |
| 15 | finish |
| 16 | endif |
| 17 | |
| 18 | syn case ignore |
| 19 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 20 | " storage types |
| 21 | syn match asmType "\.long" |
| 22 | syn match asmType "\.ascii" |
| 23 | syn match asmType "\.asciz" |
| 24 | syn match asmType "\.byte" |
| 25 | syn match asmType "\.double" |
| 26 | syn match asmType "\.float" |
| 27 | syn match asmType "\.hword" |
| 28 | syn match asmType "\.int" |
| 29 | syn match asmType "\.octa" |
| 30 | syn match asmType "\.quad" |
| 31 | syn match asmType "\.short" |
| 32 | syn match asmType "\.single" |
| 33 | syn match asmType "\.space" |
| 34 | syn match asmType "\.string" |
| 35 | syn match asmType "\.word" |
| 36 | |
| 37 | syn match asmLabel "[a-z_][a-z0-9_]*:"he=e-1 |
| 38 | syn match asmIdentifier "[a-z_][a-z0-9_]*" |
| 39 | |
| 40 | " Various #'s as defined by GAS ref manual sec 3.6.2.1 |
| 41 | " Technically, the first decNumber def is actually octal, |
| 42 | " since the value of 0-7 octal is the same as 0-7 decimal, |
| 43 | " I prefer to map it as decimal: |
| 44 | syn match decNumber "0\+[1-7]\=[\t\n$,; ]" |
| 45 | syn match decNumber "[1-9]\d*" |
| 46 | syn match octNumber "0[0-7][0-7]\+" |
| 47 | syn match hexNumber "0[xX][0-9a-fA-F]\+" |
| 48 | syn match binNumber "0[bB][0-1]*" |
| 49 | |
Bram Moolenaar | 00a927d | 2010-05-14 23:24:24 +0200 | [diff] [blame] | 50 | syn keyword asmTodo contained TODO |
| 51 | |
| 52 | " GAS supports various comment markers as described here: |
| 53 | " http://sourceware.org/binutils/docs-2.19/as/Comments.html |
| 54 | " I have commented out the ARM comment marker "@" by default as I think more |
| 55 | " people are using "@" with the .type directive. See |
| 56 | " http://sourceware.org/binutils/docs-2.19/as/Type.html |
| 57 | syn region asmComment start="/\*" end="\*/" contains=asmTodo |
| 58 | syn match asmComment "[#;!|].*" contains=asmTodo |
| 59 | " syn match asmComment "@.*" contains=asmTodo |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 60 | |
| 61 | syn match asmInclude "\.include" |
| 62 | syn match asmCond "\.if" |
| 63 | syn match asmCond "\.else" |
| 64 | syn match asmCond "\.endif" |
| 65 | syn match asmMacro "\.macro" |
| 66 | syn match asmMacro "\.endm" |
| 67 | |
| 68 | syn match asmDirective "\.[a-z][a-z]\+" |
| 69 | |
| 70 | |
| 71 | syn case match |
| 72 | |
| 73 | " Define the default highlighting. |
| 74 | " For version 5.7 and earlier: only when not done already |
| 75 | " For version 5.8 and later: only when an item doesn't have highlighting yet |
| 76 | if version >= 508 || !exists("did_asm_syntax_inits") |
| 77 | if version < 508 |
| 78 | let did_asm_syntax_inits = 1 |
| 79 | command -nargs=+ HiLink hi link <args> |
| 80 | else |
| 81 | command -nargs=+ HiLink hi def link <args> |
| 82 | endif |
| 83 | |
| 84 | " The default methods for highlighting. Can be overridden later |
| 85 | HiLink asmSection Special |
| 86 | HiLink asmLabel Label |
| 87 | HiLink asmComment Comment |
Bram Moolenaar | 00a927d | 2010-05-14 23:24:24 +0200 | [diff] [blame] | 88 | HiLink asmTodo Todo |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 89 | HiLink asmDirective Statement |
| 90 | |
| 91 | HiLink asmInclude Include |
| 92 | HiLink asmCond PreCondit |
| 93 | HiLink asmMacro Macro |
| 94 | |
| 95 | HiLink hexNumber Number |
| 96 | HiLink decNumber Number |
| 97 | HiLink octNumber Number |
| 98 | HiLink binNumber Number |
| 99 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 100 | HiLink asmIdentifier Identifier |
| 101 | HiLink asmType Type |
| 102 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 103 | delcommand HiLink |
| 104 | endif |
| 105 | |
| 106 | let b:current_syntax = "asm" |
| 107 | |
| 108 | " vim: ts=8 |