1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445
|
# Google Go (golang) syntax
# (c) 2012 Matthias S. Benkmann
# License: http://creativecommons.org/licenses/by/3.0/deed.en_US
# Small modifications by jjjordan to better suit white backgrounds and 16-color
# consoles. (Original colors commented out below)
# Standard colors:
#
# Foreground:
# white cyan magenta blue yellow green red black
#
# Background:
# bg_white bg_cyan bg_magenta bg_blue bg_yellow bg_green bg_red bg_black
#
#
# For 16 color and 256 color xterms: "export TERM=xterm-16color", the following
# brighter than normal colors are available ( Note that you need an xterm which
# was compiled to support 16 or 256 colors and a matching termcap/terminfo entry
# for it.)
#
# Foreground:
# WHITE CYAN MAGENTA BLUE YELLOW GREEN RED BLACK
#
# Background:
# bg_WHITE bg_CYAN bg_MAGENTA bg_BLUE bg_YELLOW bg_GREEN bg_RED bg_BLACK
#
#
# For 256 color xterm: "export TERM=xterm-256color", the following become available
# ( Note that you need an xterm which was compiled to support 256 colors and a
# matching termcap/terminfo entry for it. )
#
# fg_RGB and bg_RGB, where R, G, and B range from 0 - 5. So: fg_500 is bright red.
#
# fg_NN and bg_NN give shades of grey, where the intensity, NN, ranges from 0 - 23.
=Idle
=Error red bold
=ErrorDigit yellow bold bg_red
=Comment green
=SingleQuoted cyan
=DoubleQuoted cyan
=BackQuoted cyan
=Escape bold cyan
=Operator bold cyan
=Parentheses #bold yellow
=Brackets yellow
=Brace magenta
=Semicolon #bold yellow
=Period bold
=PeriodDecimal red
=Number red
=Constant red
=Comma #bold yellow
=Identifier #fg_333
=ExportedIdentifier #fg_444
=Keyword bold
=Type bold
=BuiltinFunction bold
##################### main #########################
:main Idle
* keyword_or_identifier noeat buffer
" \t" main
"\n" main
"/" maybe_comment recolor=-1
"'" single_quoted recolor=-1
"\"" double_quoted recolor=-1
"`" back_quoted recolor=-1
"+&=!|*^<>:%-" operator noeat
"()" parentheses noeat
"[]" brackets noeat
"{}" curlies noeat
";" semicolon noeat
"," comma noeat
"." period
"0" number0 recolor=-1
"1-9" float noeat
"#$@~" error noeat
#################### error ##########################
:error Error
* error
"\n" main
"/" maybe_comment_err recolor=-1
:maybe_comment_err Operator
* error noeat recolor=-2
"/" line_comment recolor=-2
"*" block_comment recolor=-2
################## comments #########################
:maybe_comment Operator
* main noeat
"/" line_comment recolor=-2
"*" block_comment recolor=-2
:line_comment Comment
* line_comment
"\n" main
:block_comment Comment
* block_comment
"*" maybe_end_block_comment
:maybe_end_block_comment Comment
* block_comment noeat
"/" main
################ strings ############################
:single_quoted SingleQuoted
* single_quoted
"'" main
"\\" single_quoted call=.escape() recolor=-1
"\n" error
:double_quoted DoubleQuoted
* double_quoted
"\"" main
"\\" double_quoted call=.escape() recolor=-1
"\n" error
:back_quoted BackQuoted
* back_quoted
"`" main
################### operators #######################
:operator Operator
* main
:parentheses Parentheses
* main
:brackets Brackets
* main
:curlies Brace
* main
:semicolon Semicolon
* main
:comma Comma
* main
##################### period #######################
:period Period
* period_other noeat recolor=-2
"0-9" period_decimal noeat recolor=-2
:period_other Period
* main noeat
:period_decimal PeriodDecimal
* float_no_period noeat
###### START .subr for underscores in decimal, hexadecimal, octal, and binary constants ######
.subr uscore_num
:uscore_num Number
* error_digit noeat recolor=-2
.ifdef dec
"0-9" uscore_num_end return noeat
.endif
.ifdef hex
"0-9a-fA-F" uscore_num_end return noeat
.endif
.ifdef oct
"0-7" uscore_num_end return noeat
.endif
.ifdef bin
"01" uscore_num_end return noeat
.endif
:error_digit ErrorDigit
* uscore_num_end noeat
"0-9a-fA-F_" error_digit
:uscore_num_end Number
* main return noeat
.end
###### END .subr for underscores in decimal, hexadecimal, octal, and binary constants ######
################### numbers ####################
:float_no_period Number
* end_of_number noeat
"0-9" float_no_period
"_" float_no_period call=.uscore_num(dec)
"eE" integer
:integer Number
* error noeat
"+-" unsigned
"0-9" unsigned_or_end
:unsigned Number
* error noeat
"0-9" unsigned_or_end
"_" float_no_period call=.uscore_num(dec)
:unsigned_or_end Number
* end_of_number noeat
"0-9" unsigned_or_end
"_" unsigned_or_end call=.uscore_num(dec)
:end_of_number Number
* main noeat
"i" main # imaginary number suffix
:number0 Number
* end_of_number noeat
"xX" hex
"oO" oct
"bB" bin
"." period_decimal recolor=-1
# 099i is a valid imaginary number, 099.0 is a valid float,
# but 099 is an invalid octal.
#We don't check for this and simply lump both cases together.
"0-9" imaginary_or_octal
"_" imaginary_or_octal call=.uscore_num(dec)
:imaginary_or_octal Number
* float noeat
"i" end_of_number noeat
"0-7" imaginary_or_octal
"8-9" imaginary_or_float mark
"_" imaginary_or_octal call=.uscore_num(dec)
:imaginary_or_float Number
* broken_octal noeat
"." period_decimal recolor=-1
"i" end_of_number noeat
"0-9" imaginary_or_float
"_" imaginary_or_octal call=.uscore_num(dec)
:broken_octal ErrorDigit
* broken_octal_2 noeat recolormark
:broken_octal_2 ErrorDigit
* end_of_number noeat call=.uscore_num()
:hex Number
* end_of_number noeat
"pP" integer
"0-9a-fA-F" hex
"_" hex call=.uscore_num(hex)
"." maybe_radix mark
:maybe_radix Number
* end_of_number noeat
"0-9a-fA-F" hex
"_" hex call=.uscore_num(hex)
"pP" integer call=.uscore_num(dec)
:oct Number
* end_of_number noeat
"0-7" oct
"8-9a-fA-F" end_of_number call=.uscore_num()
"_" oct call=.uscore_num(oct)
:bin Number
* end_of_number noeat
"01" bin
"2-9a-fA-F" end_of_number call=.uscore_num()
"_" bin call=.uscore_num(bin)
:float Number
* end_of_number noeat
"0-9" float
"_" float call=.uscore_num(dec)
"." period_decimal recolor=-1
"eEpP" integer
"a-dfA-DF" end_of_number call=.uscore_num()
################# keywords and identifiers ##########################
:keyword_or_identifier Identifier
* identifier
"A-Z" exported_identifier recolor=-1
"a-z_" keyword_or_identifier2
:exported_identifier ExportedIdentifier
* exported_identifier
"\x01-/:-@[-^`{-\x7f" main noeat
:identifier Identifier
* identifier
"\x01-/:-@[-^`{-\x7f" main noeat
:keyword_or_identifier2 Identifier
* identifier
"a-zA-Z_0-9" keyword_or_identifier2
"\x01-/:-@[-^`{-\x7f" main noeat hold strings
"_" keyword
"break" keyword
"default" keyword
"func" keyword
"interface" keyword
"select" keyword
"case" keyword
"defer" keyword
"go" keyword
"map" keyword
"struct" keyword
"chan" keyword
"else" keyword
"goto" keyword
"package" keyword
"switch" keyword
"const" keyword
"fallthrough" keyword
"if" keyword
"range" keyword
"type" keyword
"continue" keyword
"for" keyword
"import" keyword
"return" keyword
"var" keyword
"true" constant
"false" constant
"nil" constant
"iota" constant
"byte" type
"rune" type
"int" type
"uint" type
"uintptr" type
"uint8" type
"uint16" type
"uint32" type
"uint64" type
"int8" type
"int16" type
"int32" type
"int64" type
"float32" type
"float64" type
"complex64" type
"complex128" type
"bool" type
"string" type
"error" type
"delete" builtin
"make" builtin
"len" builtin
"cap" builtin
"new" builtin
"copy" builtin
"append" builtin
"close" builtin
"complex" builtin
"imag" builtin
"panic" builtin
"print" builtin
"println" builtin
"real" builtin
"recover" builtin
done
:keyword Keyword
* main noeat
:constant Constant
* main noeat
:type Type
* main noeat
:builtin BuiltinFunction
* main noeat
########################## .subr escape START ######################################
.subr escape
:esc Escape
* esc_err noeat
"abfnrtv'\"" whatever return
# For some reason joe doesn't interpret \\ properly if merged with the
# previous case. So create a separate case for it.
"\\" whatever return
"x" hex2
"u" hex4
"U" hex8
"0-3" oct2
:hex8 Escape
* esc_err noeat
"a-fA-F0-9" hex7
:hex7 Escape
* esc_err noeat
"a-fA-F0-9" hex6
:hex6 Escape
* esc_err noeat
"a-fA-F0-9" hex5
:hex5 Escape
* esc_err noeat
"a-fA-F0-9" hex4
:hex4 Escape
* esc_err noeat
"a-fA-F0-9" hex3
:hex3 Escape
* esc_err noeat
"a-fA-F0-9" hex2
:hex2 Escape
* esc_err noeat
"a-fA-F0-9" hex1
:hex1 Escape
* esc_err noeat
"a-fA-F0-9" whatever return
:oct2 Escape
* esc_err noeat
"0-7" oct1
:oct1 Escape
* esc_err noeat
"0-7" whatever return
:esc_err Error
* esc_err return
"\n" esc_err_newline noeat recolor=-2
:esc_err_newline Error
* esc_err return noeat
.end
########################## .subr escape END ######################################
|