Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | " Vim syntax file |
| 2 | " Language: JAL |
| 3 | " Version: 0.1 |
| 4 | " Last Change: 2003 May 11 |
| 5 | " Maintainer: Mark Gross <mark@thegnar.org> |
| 6 | " This is a syntax definition for the JAL language. |
| 7 | " It is based on the Source Forge compiler source code. |
| 8 | " https://sourceforge.net/projects/jal/ |
| 9 | " |
| 10 | " TODO test. |
| 11 | |
| 12 | " For version 5.x: Clear all syntax items |
| 13 | " For version 6.x: Quit when a syntax file was already loaded |
| 14 | if version < 600 |
| 15 | syntax clear |
| 16 | elseif exists("b:current_syntax") |
| 17 | finish |
| 18 | endif |
| 19 | |
| 20 | syn case ignore |
| 21 | syn sync lines=250 |
| 22 | |
| 23 | syn keyword picTodo NOTE TODO XXX contained |
| 24 | |
| 25 | syn match picIdentifier "[a-z_$][a-z0-9_$]*" |
| 26 | syn match picLabel "^[A-Z_$][A-Z0-9_$]*" |
| 27 | syn match picLabel "^[A-Z_$][A-Z0-9_$]*:"me=e-1 |
| 28 | |
| 29 | syn match picASCII "A\='.'" |
| 30 | syn match picBinary "B'[0-1]\+'" |
| 31 | syn match picDecimal "D'\d\+'" |
| 32 | syn match picDecimal "\d\+" |
| 33 | syn match picHexadecimal "0x\x\+" |
| 34 | syn match picHexadecimal "H'\x\+'" |
| 35 | syn match picHexadecimal "[0-9]\x*h" |
| 36 | syn match picOctal "O'[0-7]\o*'" |
| 37 | |
| 38 | syn match picComment ";.*" contains=picTodo |
| 39 | |
| 40 | syn region picString start=+"+ end=+"+ |
| 41 | |
| 42 | syn keyword picRegister indf tmr0 pcl status fsr port_a port_b port_c port_d port_e x84_eedata x84_eeadr pclath intcon |
| 43 | syn keyword picRegister f877_tmr1l f877_tmr1h f877_t1con f877_t2con f877_ccpr1l f877_ccpr1h f877_ccp1con |
| 44 | syn keyword picRegister f877_pir1 f877_pir2 f877_pie1 f877_adcon1 f877_adcon0 f877_pr2 f877_adresl f877_adresh |
| 45 | syn keyword picRegister f877_eeadr f877_eedath f877_eeadrh f877_eedata f877_eecon1 f877_eecon2 f628_EECON2 |
| 46 | syn keyword picRegister f877_rcsta f877_txsta f877_spbrg f877_txreg f877_rcreg f628_EEDATA f628_EEADR f628_EECON1 |
| 47 | |
| 48 | " Register --- bits |
| 49 | " STATUS |
| 50 | syn keyword picRegisterPart status_c status_dc status_z status_pd |
| 51 | syn keyword picRegisterPart status_to status_rp0 status_rp1 status_irp |
| 52 | |
| 53 | " pins |
| 54 | syn keyword picRegisterPart pin_a0 pin_a1 pin_a2 pin_a3 pin_a4 pin_a5 |
| 55 | syn keyword picRegisterPart pin_b0 pin_b1 pin_b2 pin_b3 pin_b4 pin_b5 pin_b6 pin_b7 |
| 56 | syn keyword picRegisterPart pin_c0 pin_c1 pin_c2 pin_c3 pin_c4 pin_c5 pin_c6 pin_c7 |
| 57 | syn keyword picRegisterPart pin_d0 pin_d1 pin_d2 pin_d3 pin_d4 pin_d5 pin_d6 pin_d7 |
| 58 | syn keyword picRegisterPart pin_e0 pin_e1 pin_e2 |
| 59 | |
| 60 | syn keyword picPortDir port_a_direction port_b_direction port_c_direction port_d_direction port_e_direction |
| 61 | |
| 62 | syn match picPinDir "pin_a[012345]_direction" |
| 63 | syn match picPinDir "pin_b[01234567]_direction" |
| 64 | syn match picPinDir "pin_c[01234567]_direction" |
| 65 | syn match picPinDir "pin_d[01234567]_direction" |
| 66 | syn match picPinDir "pin_e[012]_direction" |
| 67 | |
| 68 | |
| 69 | " INTCON |
| 70 | syn keyword picRegisterPart intcon_gie intcon_eeie intcon_peie intcon_t0ie intcon_inte |
| 71 | syn keyword picRegisterPart intcon_rbie intcon_t0if intcon_intf intcon_rbif |
| 72 | |
| 73 | " TIMER |
| 74 | syn keyword picRegisterPart t1ckps1 t1ckps0 t1oscen t1sync tmr1cs tmr1on tmr1ie tmr1if |
| 75 | |
| 76 | "cpp bits |
| 77 | syn keyword picRegisterPart ccp1x ccp1y |
| 78 | |
| 79 | " adcon bits |
| 80 | syn keyword picRegisterPart adcon0_go adcon0_ch0 adcon0_ch1 adcon0_ch2 |
| 81 | |
| 82 | " EECON |
| 83 | syn keyword picRegisterPart eecon1_rd eecon1_wr eecon1_wren eecon1_wrerr eecon1_eepgd |
| 84 | syn keyword picRegisterPart f628_eecon1_rd f628_eecon1_wr f628_eecon1_wren f628_eecon1_wrerr |
| 85 | |
| 86 | " usart |
| 87 | syn keyword picRegisterPart tx9 txen sync brgh tx9d |
| 88 | syn keyword picRegisterPart spen rx9 cren ferr oerr rx9d |
| 89 | syn keyword picRegisterPart TXIF RCIF |
| 90 | |
| 91 | " OpCodes... |
| 92 | syn keyword picOpcode addlw andlw call clrwdt goto iorlw movlw option retfie retlw return sleep sublw tris |
| 93 | syn keyword picOpcode xorlw addwf andwf clrf clrw comf decf decfsz incf incfsz retiw iorwf movf movwf nop |
| 94 | syn keyword picOpcode rlf rrf subwf swapf xorwf bcf bsf btfsc btfss skpz skpnz setz clrz skpc skpnc setc clrc |
| 95 | syn keyword picOpcode skpdc skpndc setdc clrdc movfw tstf bank page HPAGE mullw mulwf cpfseq cpfsgt cpfslt banka bankb |
| 96 | |
| 97 | |
| 98 | syn keyword jalBoolean true false |
| 99 | syn keyword jalBoolean off on |
| 100 | syn keyword jalBit high low |
| 101 | syn keyword jalConstant Input Output all_input all_output |
| 102 | syn keyword jalConditional if else then elsif end if |
| 103 | syn keyword jalLabel goto |
| 104 | syn keyword jalRepeat for while forever loop |
| 105 | syn keyword jalStatement procedure function |
| 106 | syn keyword jalStatement return end volatile const var |
| 107 | syn keyword jalType bit byte |
| 108 | |
| 109 | syn keyword jalModifier interrupt assembler asm put get |
| 110 | syn keyword jalStatement out in is begin at |
| 111 | syn keyword jalDirective pragma jump_table target target_clock target_chip name error test assert |
| 112 | syn keyword jalPredefined hs xt rc lp internal 16c84 16f84 16f877 sx18 sx28 12c509a 12c508 |
| 113 | syn keyword jalPredefined 12ce674 16f628 18f252 18f242 18f442 18f452 12f629 12f675 16f88 |
| 114 | syn keyword jalPredefined 16f876 16f873 sx_12 sx18 sx28 pic_12 pic_14 pic_16 |
| 115 | |
| 116 | syn keyword jalDirective chip osc clock fuses cpu watchdog powerup protection |
| 117 | |
| 118 | syn keyword jalFunction bank_0 bank_1 bank_2 bank_3 bank_4 bank_5 bank_6 bank_7 trisa trisb trisc trisd trise |
| 119 | syn keyword jalFunction _trisa_flush _trisb_flush _trisc_flush _trisd_flush _trise_flush |
| 120 | |
| 121 | syn keyword jalPIC local idle_loop |
| 122 | |
| 123 | syn region jalAsm matchgroup=jalAsmKey start="\<assembler\>" end="\<end assembler\>" contains=jalComment,jalPreProc,jalLabel,picIdentifier, picLabel,picASCII,picDecimal,picHexadecimal,picOctal,picComment,picString,picRegister,picRigisterPart,picOpcode,picDirective,jalPIC |
| 124 | syn region jalAsm matchgroup=jalAsmKey start="\<asm\>" end=/$/ contains=jalComment,jalPreProc,jalLabel,picIdentifier, picLabel,picASCII,picDecimal,picHexadecimal,picOctal,picComment,picString,picRegister,picRigisterPart,picOpcode,picDirective,jalPIC |
| 125 | |
| 126 | syn region jalPsudoVars matchgroup=jalPsudoVarsKey start="\<'put\>" end="/<is/>" contains=jalComment |
| 127 | |
| 128 | syn match jalStringEscape contained "#[12][0-9]\=[0-9]\=" |
| 129 | syn match jalIdentifier "\<[a-zA-Z_][a-zA-Z0-9_]*\>" |
| 130 | syn match jalSymbolOperator "[+\-/*=]" |
| 131 | syn match jalSymbolOperator "!" |
| 132 | syn match jalSymbolOperator "<" |
| 133 | syn match jalSymbolOperator ">" |
| 134 | syn match jalSymbolOperator "<=" |
| 135 | syn match jalSymbolOperator ">=" |
| 136 | syn match jalSymbolOperator "!=" |
| 137 | syn match jalSymbolOperator "==" |
| 138 | syn match jalSymbolOperator "<<" |
| 139 | syn match jalSymbolOperator ">>" |
| 140 | syn match jalSymbolOperator "|" |
| 141 | syn match jalSymbolOperator "&" |
| 142 | syn match jalSymbolOperator "%" |
| 143 | syn match jalSymbolOperator "?" |
| 144 | syn match jalSymbolOperator "[()]" |
| 145 | syn match jalSymbolOperator "[\^.]" |
| 146 | syn match jalLabel "[\^]*:" |
| 147 | |
| 148 | syn match jalNumber "-\=\<\d[0-9_]\+\>" |
| 149 | syn match jalHexNumber "0x[0-9A-Fa-f_]\+\>" |
| 150 | syn match jalBinNumber "0b[01_]\+\>" |
| 151 | |
| 152 | " String |
| 153 | "wrong strings |
| 154 | syn region jalStringError matchgroup=jalStringError start=+"+ end=+"+ end=+$+ contains=jalStringEscape |
| 155 | |
| 156 | "right strings |
| 157 | syn region jalString matchgroup=jalString start=+'+ end=+'+ oneline contains=jalStringEscape |
| 158 | " To see the start and end of strings: |
| 159 | syn region jalString matchgroup=jalString start=+"+ end=+"+ oneline contains=jalStringEscapeGPC |
| 160 | |
| 161 | syn keyword jalTodo contained TODO |
| 162 | syn region jalComment start=/-- / end=/$/ oneline contains=jalTodo |
| 163 | syn region jalComment start=/--\t/ end=/$/ oneline contains=jalTodo |
| 164 | syn match jalComment /--\_$/ |
| 165 | syn region jalPreProc start="include" end=/$/ contains=JalComment,jalToDo |
| 166 | |
| 167 | |
| 168 | if exists("jal_no_tabs") |
| 169 | syn match jalShowTab "\t" |
| 170 | endif |
| 171 | |
| 172 | |
| 173 | " Define the default highlighting. |
| 174 | " For version 5.7 and earlier: only when not done already |
| 175 | " For version 5.8 and later: only when an item doesn't have highlighting yet |
| 176 | if version >= 508 || !exists("did_jal_syn_inits") |
| 177 | if version < 508 |
| 178 | let did_jal_syn_inits = 1 |
| 179 | command -nargs=+ HiLink hi link <args> |
| 180 | else |
| 181 | command -nargs=+ HiLink hi def link <args> |
| 182 | endif |
| 183 | |
| 184 | HiLink jalAcces jalStatement |
| 185 | HiLink jalBoolean Boolean |
| 186 | HiLink jalBit Boolean |
| 187 | HiLink jalComment Comment |
| 188 | HiLink jalConditional Conditional |
| 189 | HiLink jalConstant Constant |
| 190 | HiLink jalDelimiter Identifier |
| 191 | HiLink jalDirective PreProc |
| 192 | HiLink jalException Exception |
| 193 | HiLink jalFloat Float |
| 194 | HiLink jalFunction Function |
| 195 | HiLink jalPsudoVarsKey Function |
| 196 | HiLink jalLabel Label |
| 197 | HiLink jalMatrixDelimiter Identifier |
| 198 | HiLink jalModifier Type |
| 199 | HiLink jalNumber Number |
| 200 | HiLink jalBinNumber Number |
| 201 | HiLink jalHexNumber Number |
| 202 | HiLink jalOperator Operator |
| 203 | HiLink jalPredefined Constant |
| 204 | HiLink jalPreProc PreProc |
| 205 | HiLink jalRepeat Repeat |
| 206 | HiLink jalStatement Statement |
| 207 | HiLink jalString String |
| 208 | HiLink jalStringEscape Special |
| 209 | HiLink jalStringEscapeGPC Special |
| 210 | HiLink jalStringError Error |
| 211 | HiLink jalStruct jalStatement |
| 212 | HiLink jalSymbolOperator jalOperator |
| 213 | HiLink jalTodo Todo |
| 214 | HiLink jalType Type |
| 215 | HiLink jalUnclassified Statement |
| 216 | HiLink jalAsm Assembler |
| 217 | HiLink jalError Error |
| 218 | HiLink jalAsmKey Statement |
| 219 | HiLink jalPIC Statement |
| 220 | |
| 221 | HiLink jalShowTab Error |
| 222 | |
| 223 | HiLink picTodo Todo |
| 224 | HiLink picComment Comment |
| 225 | HiLink picDirective Statement |
| 226 | HiLink picLabel Label |
| 227 | HiLink picString String |
| 228 | |
| 229 | HiLink picOpcode Keyword |
| 230 | HiLink picRegister Structure |
| 231 | HiLink picRegisterPart Special |
| 232 | HiLink picPinDir SPecial |
| 233 | HiLink picPortDir SPecial |
| 234 | |
| 235 | HiLink picASCII String |
| 236 | HiLink picBinary Number |
| 237 | HiLink picDecimal Number |
| 238 | HiLink picHexadecimal Number |
| 239 | HiLink picOctal Number |
| 240 | |
| 241 | HiLink picIdentifier Identifier |
| 242 | |
| 243 | delcommand HiLink |
| 244 | endif |
| 245 | |
| 246 | |
| 247 | let b:current_syntax = "jal" |
| 248 | |
| 249 | " vim: ts=8 sw=2 |