neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

nqc.vim (14068B)


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