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> |
| 6 | " Last Change: 2010 Jan 9 |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 7 | |
| 8 | " For version 5.x: Clear all syntax items |
Bram Moolenaar | 555cdc2 | 2010-01-12 21:31:21 +0100 | [diff] [blame] | 9 | " 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] | 10 | if version < 600 |
| 11 | syntax clear |
| 12 | elseif exists("b:current_syntax") |
| 13 | finish |
| 14 | endif |
| 15 | |
| 16 | syn case ignore |
| 17 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 18 | " storage types |
| 19 | syn match asmType "\.long" |
| 20 | syn match asmType "\.ascii" |
| 21 | syn match asmType "\.asciz" |
| 22 | syn match asmType "\.byte" |
| 23 | syn match asmType "\.double" |
| 24 | syn match asmType "\.float" |
| 25 | syn match asmType "\.hword" |
| 26 | syn match asmType "\.int" |
| 27 | syn match asmType "\.octa" |
| 28 | syn match asmType "\.quad" |
| 29 | syn match asmType "\.short" |
| 30 | syn match asmType "\.single" |
| 31 | syn match asmType "\.space" |
| 32 | syn match asmType "\.string" |
| 33 | syn match asmType "\.word" |
| 34 | |
| 35 | syn match asmLabel "[a-z_][a-z0-9_]*:"he=e-1 |
| 36 | syn match asmIdentifier "[a-z_][a-z0-9_]*" |
| 37 | |
| 38 | " Various #'s as defined by GAS ref manual sec 3.6.2.1 |
| 39 | " Technically, the first decNumber def is actually octal, |
| 40 | " since the value of 0-7 octal is the same as 0-7 decimal, |
| 41 | " I prefer to map it as decimal: |
| 42 | syn match decNumber "0\+[1-7]\=[\t\n$,; ]" |
| 43 | syn match decNumber "[1-9]\d*" |
| 44 | syn match octNumber "0[0-7][0-7]\+" |
| 45 | syn match hexNumber "0[xX][0-9a-fA-F]\+" |
| 46 | syn match binNumber "0[bB][0-1]*" |
| 47 | |
Bram Moolenaar | 555cdc2 | 2010-01-12 21:31:21 +0100 | [diff] [blame] | 48 | syn match asmComment "#.*" |
| 49 | syn region asmComment start="/\*" end="\*/" |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 50 | |
| 51 | syn match asmInclude "\.include" |
| 52 | syn match asmCond "\.if" |
| 53 | syn match asmCond "\.else" |
| 54 | syn match asmCond "\.endif" |
| 55 | syn match asmMacro "\.macro" |
| 56 | syn match asmMacro "\.endm" |
| 57 | |
| 58 | syn match asmDirective "\.[a-z][a-z]\+" |
| 59 | |
| 60 | |
| 61 | syn case match |
| 62 | |
| 63 | " Define the default highlighting. |
| 64 | " For version 5.7 and earlier: only when not done already |
| 65 | " For version 5.8 and later: only when an item doesn't have highlighting yet |
| 66 | if version >= 508 || !exists("did_asm_syntax_inits") |
| 67 | if version < 508 |
| 68 | let did_asm_syntax_inits = 1 |
| 69 | command -nargs=+ HiLink hi link <args> |
| 70 | else |
| 71 | command -nargs=+ HiLink hi def link <args> |
| 72 | endif |
| 73 | |
| 74 | " The default methods for highlighting. Can be overridden later |
| 75 | HiLink asmSection Special |
| 76 | HiLink asmLabel Label |
| 77 | HiLink asmComment Comment |
| 78 | HiLink asmDirective Statement |
| 79 | |
| 80 | HiLink asmInclude Include |
| 81 | HiLink asmCond PreCondit |
| 82 | HiLink asmMacro Macro |
| 83 | |
| 84 | HiLink hexNumber Number |
| 85 | HiLink decNumber Number |
| 86 | HiLink octNumber Number |
| 87 | HiLink binNumber Number |
| 88 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 89 | HiLink asmIdentifier Identifier |
| 90 | HiLink asmType Type |
| 91 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 92 | delcommand HiLink |
| 93 | endif |
| 94 | |
| 95 | let b:current_syntax = "asm" |
| 96 | |
| 97 | " vim: ts=8 |