1" Vim syntax file 2" Language: NQC - Not Quite C, for LEGO mindstorms 3" NQC homepage: http://www.enteract.com/~dbaum/nqc/ 4" Maintainer: Stefan Scherer <stefan@enotes.de> 5" Last Change: 2001 May 10 6" URL: http://www.enotes.de/twiki/pub/Home/LegoMindstorms/nqc.vim 7" Filenames: .nqc 8 9" For version 5.x: Clear all syntax items 10" For version 6.x: Quit when a syntax file was already loaded 11if version < 600 12 syntax clear 13elseif exists("b:current_syntax") 14 finish 15endif 16 17" Statements 18syn keyword nqcStatement break return continue start stop abs sign 19syn keyword nqcStatement sub task 20syn keyword nqcLabel case default 21syn keyword nqcConditional if else switch 22syn keyword nqcRepeat while for do until repeat 23 24" Scout and RCX2 25syn keyword nqcEvents acquire catch monitor 26 27" types and classes 28syn keyword nqcType int true false void 29syn keyword nqcStorageClass asm const inline 30 31 32 33" Sensors -------------------------------------------- 34" Input Sensors 35syn keyword nqcConstant SENSOR_1 SENSOR_2 SENSOR_3 36 37" Types for SetSensorType() 38syn keyword nqcConstant SENSOR_TYPE_TOUCH SENSOR_TYPE_TEMPERATURE 39syn keyword nqcConstant SENSOR_TYPE_LIGHT SENSOR_TYPE_ROTATION 40syn keyword nqcConstant SENSOR_LIGHT SENSOR_TOUCH 41 42" Modes for SetSensorMode() 43syn keyword nqcConstant SENSOR_MODE_RAW SENSOR_MODE_BOOL 44syn keyword nqcConstant SENSOR_MODE_EDGE SENSOR_MODE_PULSE 45syn keyword nqcConstant SENSOR_MODE_PERCENT SENSOR_MODE_CELSIUS 46syn keyword nqcConstant SENSOR_MODE_FAHRENHEIT SENSOR_MODE_ROTATION 47 48" Sensor configurations for SetSensor() 49syn keyword nqcConstant SENSOR_TOUCH SENSOR_LIGHT SENSOR_ROTATION 50syn keyword nqcConstant SENSOR_CELSIUS SENSOR_FAHRENHEIT SENSOR_PULSE 51syn keyword nqcConstant SENSOR_EDGE 52 53" Functions - All 54syn keyword nqcFunction ClearSensor 55syn keyword nqcFunction SensorValue SensorType 56 57" Functions - RCX 58syn keyword nqcFunction SetSensor SetSensorType 59syn keyword nqcFunction SensorValueBool 60 61" Functions - RCX, CyberMaster 62syn keyword nqcFunction SetSensorMode SensorMode 63 64" Functions - RCX, Scout 65syn keyword nqcFunction SensorValueRaw 66 67" Functions - Scout 68syn keyword nqcFunction SetSensorLowerLimit SetSensorUpperLimit 69syn keyword nqcFunction SetSensorHysteresis CalibrateSensor 70 71 72" Outputs -------------------------------------------- 73" Outputs for On(), Off(), etc. 74syn keyword nqcConstant OUT_A OUT_B OUT_C 75 76" Modes for SetOutput() 77syn keyword nqcConstant OUT_ON OUT_OFF OUT_FLOAT 78 79" Directions for SetDirection() 80syn keyword nqcConstant OUT_FWD OUT_REV OUT_TOGGLE 81 82" Output power for SetPower() 83syn keyword nqcConstant OUT_LOW OUT_HALF OUT_FULL 84 85" Functions - All 86syn keyword nqcFunction SetOutput SetDirection SetPower OutputStatus 87syn keyword nqcFunction On Off Float Fwd Rev Toggle 88syn keyword nqcFunction OnFwd OnRev OnFor 89 90" Functions - RXC2, Scout 91syn keyword nqcFunction SetGlobalOutput SetGlobalDirection SetMaxPower 92syn keyword nqcFunction GlobalOutputStatus 93 94 95" Sound ---------------------------------------------- 96" Sounds for PlaySound() 97syn keyword nqcConstant SOUND_CLICK SOUND_DOUBLE_BEEP SOUND_DOWN 98syn keyword nqcConstant SOUND_UP SOUND_LOW_BEEP SOUND_FAST_UP 99 100" Functions - All 101syn keyword nqcFunction PlaySound PlayTone 102 103" Functions - RCX2, Scout 104syn keyword nqcFunction MuteSound UnmuteSound ClearSound 105syn keyword nqcFunction SelectSounds 106 107 108" LCD ------------------------------------------------ 109" Modes for SelectDisplay() 110syn keyword nqcConstant DISPLAY_WATCH DISPLAY_SENSOR_1 DISPLAY_SENSOR_2 111syn keyword nqcConstant DISPLAY_SENSOR_3 DISPLAY_OUT_A DISPLAY_OUT_B 112syn keyword nqcConstant DISPLAY_OUT_C 113" RCX2 114syn keyword nqcConstant DISPLAY_USER 115 116" Functions - RCX 117syn keyword nqcFunction SelectDisplay 118" Functions - RCX2 119syn keyword nqcFunction SetUserDisplay 120 121 122" Communication -------------------------------------- 123" Messages - RCX, Scout ------------------------------ 124" Tx power level for SetTxPower() 125syn keyword nqcConstant TX_POWER_LO TX_POWER_HI 126 127" Functions - RCX, Scout 128syn keyword nqcFunction Message ClearMessage SendMessage SetTxPower 129 130" Serial - RCX2 -------------------------------------- 131" for SetSerialComm() 132syn keyword nqcConstant SERIAL_COMM_DEFAULT SERIAL_COMM_4800 133syn keyword nqcConstant SERIAL_COMM_DUTY25 SERIAL_COMM_76KHZ 134 135" for SetSerialPacket() 136syn keyword nqcConstant SERIAL_PACKET_DEFAULT SERIAL_PACKET_PREAMBLE 137syn keyword nqcConstant SERIAL_PACKET_NEGATED SERIAL_PACKET_CHECKSUM 138syn keyword nqcConstant SERIAL_PACKET_RCX 139 140" Functions - RCX2 141syn keyword nqcFunction SetSerialComm SetSerialPacket SetSerialData 142syn keyword nqcFunction SerialData SendSerial 143 144" VLL - Scout ---------------------------------------- 145" Functions - Scout 146syn keyword nqcFunction SendVLL 147 148 149" Timers --------------------------------------------- 150" Functions - All 151syn keyword nqcFunction ClearTimer Timer 152 153" Functions - RCX2 154syn keyword nqcFunction SetTimer FastTimer 155 156 157" Counters ------------------------------------------- 158" Functions - RCX2, Scout 159syn keyword nqcFunction ClearCounter IncCounter DecCounter Counter 160 161 162" Access Control ------------------------------------- 163syn keyword nqcConstant ACQUIRE_OUT_A ACQUIRE_OUT_B ACQUIRE_OUT_C 164syn keyword nqcConstant ACQUIRE_SOUND 165" RCX2 only 166syn keyword nqcConstant ACQUIRE_USER_1 ACQUIRE_USER_2 ACQUIRE_USER_3 167syn keyword nqcConstant ACQUIRE_USER_4 168 169" Functions - RCX2, Scout 170syn keyword nqcFunction SetPriority 171 172 173" Events --------------------------------------------- 174" RCX2 Events 175syn keyword nqcConstant EVENT_TYPE_PRESSED EVENT_TYPE_RELEASED 176syn keyword nqcConstant EVENT_TYPE_PULSE EVENT_TYPE_EDGE 177syn keyword nqcConstant EVENT_TYPE_FAST_CHANGE EVENT_TYPE_LOW 178syn keyword nqcConstant EVENT_TYPE_NORMAL EVENT_TYPE_HIGH 179syn keyword nqcConstant EVENT_TYPE_CLICK EVENT_TYPE_DOUBLECLICK 180syn keyword nqcConstant EVENT_TYPE_MESSAGE 181 182" Scout Events 183syn keyword nqcConstant EVENT_1_PRESSED EVENT_1_RELEASED 184syn keyword nqcConstant EVENT_2_PRESSED EVENT_2_RELEASED 185syn keyword nqcConstant EVENT_LIGHT_HIGH EVENT_LIGHT_NORMAL 186syn keyword nqcConstant EVENT_LIGHT_LOW EVENT_LIGHT_CLICK 187syn keyword nqcConstant EVENT_LIGHT_DOUBLECLICK EVENT_COUNTER_0 188syn keyword nqcConstant EVENT_COUNTER_1 EVENT_TIMER_0 EVENT_TIMER_1 189syn keyword nqcConstant EVENT_TIMER_2 EVENT_MESSAGE 190 191" Functions - RCX2, Scout 192syn keyword nqcFunction ActiveEvents Event 193 194" Functions - RCX2 195syn keyword nqcFunction CurrentEvents 196syn keyword nqcFunction SetEvent ClearEvent ClearAllEvents EventState 197syn keyword nqcFunction CalibrateEvent SetUpperLimit UpperLimit 198syn keyword nqcFunction SetLowerLimit LowerLimit SetHysteresis 199syn keyword nqcFunction Hysteresis 200syn keyword nqcFunction SetClickTime ClickTime SetClickCounter 201syn keyword nqcFunction ClickCounter 202 203" Functions - Scout 204syn keyword nqcFunction SetSensorClickTime SetCounterLimit 205syn keyword nqcFunction SetTimerLimit 206 207 208" Data Logging --------------------------------------- 209" Functions - RCX 210syn keyword nqcFunction CreateDatalog AddToDatalog 211syn keyword nqcFunction UploadDatalog 212 213 214" General Features ----------------------------------- 215" Functions - All 216syn keyword nqcFunction Wait StopAllTasks Random 217syn keyword nqcFunction SetSleepTime SleepNow 218 219" Functions - RCX 220syn keyword nqcFunction Program Watch SetWatch 221 222" Functions - RCX2 223syn keyword nqcFunction SetRandomSeed SelectProgram 224syn keyword nqcFunction BatteryLevel FirmwareVersion 225 226" Functions - Scout 227" Parameters for SetLight() 228syn keyword nqcConstant LIGHT_ON LIGHT_OFF 229syn keyword nqcFunction SetScoutRules ScoutRules SetScoutMode 230syn keyword nqcFunction SetEventFeedback EventFeedback SetLight 231 232" additional CyberMaster defines 233syn keyword nqcConstant OUT_L OUT_R OUT_X 234syn keyword nqcConstant SENSOR_L SENSOR_M SENSOR_R 235" Functions - CyberMaster 236syn keyword nqcFunction Drive OnWait OnWaitDifferent 237syn keyword nqcFunction ClearTachoCounter TachoCount TachoSpeed 238syn keyword nqcFunction ExternalMotorRunning AGC 239 240 241 242" nqcCommentGroup allows adding matches for special things in comments 243syn keyword nqcTodo contained TODO FIXME XXX 244syn cluster nqcCommentGroup contains=nqcTodo 245 246"when wanted, highlight trailing white space 247if exists("nqc_space_errors") 248 if !exists("nqc_no_trail_space_error") 249 syn match nqcSpaceError display excludenl "\s\+$" 250 endif 251 if !exists("nqc_no_tab_space_error") 252 syn match nqcSpaceError display " \+\t"me=e-1 253 endif 254endif 255 256"catch errors caused by wrong parenthesis and brackets 257syn cluster nqcParenGroup contains=nqcParenError,nqcIncluded,nqcCommentSkip,@nqcCommentGroup,nqcCommentStartError,nqcCommentSkip,nqcCppOut,nqcCppOut2,nqcCppSkip,nqcNumber,nqcFloat,nqcNumbers 258if exists("nqc_no_bracket_error") 259 syn region nqcParen transparent start='(' end=')' contains=ALLBUT,@nqcParenGroup,nqcCppParen 260 " nqcCppParen: same as nqcParen but ends at end-of-line; used in nqcDefine 261 syn region nqcCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@nqcParenGroup,nqcParen 262 syn match nqcParenError display ")" 263 syn match nqcErrInParen display contained "[{}]" 264else 265 syn region nqcParen transparent start='(' end=')' contains=ALLBUT,@nqcParenGroup,nqcCppParen,nqcErrInBracket,nqcCppBracket 266 " nqcCppParen: same as nqcParen but ends at end-of-line; used in nqcDefine 267 syn region nqcCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@nqcParenGroup,nqcErrInBracket,nqcParen,nqcBracket 268 syn match nqcParenError display "[\])]" 269 syn match nqcErrInParen display contained "[\]{}]" 270 syn region nqcBracket transparent start='\[' end=']' contains=ALLBUT,@nqcParenGroup,nqcErrInParen,nqcCppParen,nqcCppBracket 271 " nqcCppBracket: same as nqcParen but ends at end-of-line; used in nqcDefine 272 syn region nqcCppBracket transparent start='\[' skip='\\$' excludenl end=']' end='$' contained contains=ALLBUT,@nqcParenGroup,nqcErrInParen,nqcParen,nqcBracket 273 syn match nqcErrInBracket display contained "[);{}]" 274endif 275 276"integer number, or floating point number without a dot and with "f". 277syn case ignore 278syn match nqcNumbers display transparent "\<\d\|\.\d" contains=nqcNumber,nqcFloat 279" Same, but without octal error (for comments) 280syn match nqcNumber display contained "\d\+\(u\=l\{0,2}\|ll\=u\)\>" 281"hex number 282syn match nqcNumber display contained "0x\x\+\(u\=l\{0,2}\|ll\=u\)\>" 283" Flag the first zero of an octal number as something special 284syn match nqcFloat display contained "\d\+f" 285"floating point number, with dot, optional exponent 286syn match nqcFloat display contained "\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\=" 287"floating point number, starting with a dot, optional exponent 288syn match nqcFloat display contained "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>" 289"floating point number, without dot, with exponent 290syn match nqcFloat display contained "\d\+e[-+]\=\d\+[fl]\=\>" 291" flag an octal number with wrong digits 292syn case match 293 294syn region nqcCommentL start="//" skip="\\$" end="$" keepend contains=@nqcCommentGroup,nqcSpaceError 295syn region nqcComment matchgroup=nqcCommentStart start="/\*" matchgroup=NONE end="\*/" contains=@nqcCommentGroup,nqcCommentStartError,nqcSpaceError 296 297" keep a // comment separately, it terminates a preproc. conditional 298syntax match nqcCommentError display "\*/" 299syntax match nqcCommentStartError display "/\*" contained 300 301 302 303 304 305syn region nqcPreCondit start="^\s*#\s*\(if\|ifdef\|ifndef\|elif\)\>" skip="\\$" end="$" end="//"me=s-1 contains=nqcComment,nqcCharacter,nqcCppParen,nqcParenError,nqcNumbers,nqcCommentError,nqcSpaceError 306syn match nqcPreCondit display "^\s*#\s*\(else\|endif\)\>" 307if !exists("nqc_no_if0") 308 syn region nqcCppOut start="^\s*#\s*if\s\+0\>" end=".\|$" contains=nqcCppOut2 309 syn region nqcCppOut2 contained start="0" end="^\s*#\s*\(endif\>\|else\>\|elif\>\)" contains=nqcSpaceError,nqcCppSkip 310 syn region nqcCppSkip contained start="^\s*#\s*\(if\>\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*#\s*endif\>" contains=nqcSpaceError,nqcCppSkip 311endif 312syn region nqcIncluded display contained start=+"+ skip=+\\\\\|\\"+ end=+"+ 313syn match nqcInclude display "^\s*#\s*include\>\s*["]" contains=nqcIncluded 314"syn match nqcLineSkip "\\$" 315syn cluster nqcPreProcGroup contains=nqcPreCondit,nqcIncluded,nqcInclude,nqcDefine,nqcErrInParen,nqcErrInBracket,nqcCppOut,nqcCppOut2,nqcCppSkip,nqcNumber,nqcFloat,nqcNumbers,nqcCommentSkip,@nqcCommentGroup,nqcCommentStartError,nqcParen,nqcBracket 316syn region nqcDefine start="^\s*#\s*\(define\|undef\)\>" skip="\\$" end="$" contains=ALLBUT,@nqcPreProcGroup 317syn region nqcPreProc start="^\s*#\s*\(pragma\>\)" skip="\\$" end="$" keepend contains=ALLBUT,@nqcPreProcGroup 318 319if !exists("nqc_minlines") 320 if !exists("nqc_no_if0") 321 let nqc_minlines = 50 " #if 0 constructs can be long 322 else 323 let nqc_minlines = 15 " mostly for () constructs 324 endif 325endif 326exec "syn sync ccomment nqcComment minlines=" . nqc_minlines 327 328" Define the default highlighting. 329" For version 5.7 and earlier: only when not done already 330" For version 5.8 and later: only when an item doesn't have highlighting yet 331if version >= 508 || !exists("did_nqc_syn_inits") 332 if version < 508 333 let did_nqc_syn_inits = 1 334 command -nargs=+ HiLink hi link <args> 335 else 336 command -nargs=+ HiLink hi def link <args> 337 endif 338 339 " The default methods for highlighting. Can be overridden later 340 HiLink nqcLabel Label 341 HiLink nqcConditional Conditional 342 HiLink nqcRepeat Repeat 343 HiLink nqcCharacter Character 344 HiLink nqcNumber Number 345 HiLink nqcFloat Float 346 HiLink nqcFunction Function 347 HiLink nqcParenError nqcError 348 HiLink nqcErrInParen nqcError 349 HiLink nqcErrInBracket nqcError 350 HiLink nqcCommentL nqcComment 351 HiLink nqcCommentStart nqcComment 352 HiLink nqcCommentError nqcError 353 HiLink nqcCommentStartError nqcError 354 HiLink nqcSpaceError nqcError 355 HiLink nqcStorageClass StorageClass 356 HiLink nqcInclude Include 357 HiLink nqcPreProc PreProc 358 HiLink nqcDefine Macro 359 HiLink nqcIncluded String 360 HiLink nqcError Error 361 HiLink nqcStatement Statement 362 HiLink nqcEvents Statement 363 HiLink nqcPreCondit PreCondit 364 HiLink nqcType Type 365 HiLink nqcConstant Constant 366 HiLink nqcCommentSkip nqcComment 367 HiLink nqcComment Comment 368 HiLink nqcTodo Todo 369 HiLink nqcCppSkip nqcCppOut 370 HiLink nqcCppOut2 nqcCppOut 371 HiLink nqcCppOut Comment 372 373 delcommand HiLink 374endif 375 376let b:current_syntax = "nqc" 377 378" vim: ts=8 379