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
|
# Google Go (golang) syntax
# (c) 2012 Matthias S. Benkmann
# License: http://creativecommons.org/licenses/by/3.0/deed.en_US
=Idle
=Bad
=Comment
=Constant
=Boolean +Constant
=String +Constant
=Character +String
=BackQuoted +String
=StringEscape +Escape
=Number +Constant
=Ident
=DefinedIdent +Ident
=Keyword
=Operator +Keyword
=Statement +Keyword
=Conditional +Statement
=Loop +Statement
=Label +DefinedIdent
=Structure +Type +Keyword
=Type
=Builtin +DefinedFunction
=Control
=Brackets +Control
=Brace +Control
=Semicolon +Control
=Comma +Control
=Period +Control
=PeriodDecimal +Period +Number
##################### 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 recolor=-1
"#$@~" error noeat
#################### error ##########################
:error Bad
* 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 comment
* line_comment
"BFHNTX" line_comment noeat call=comment_todo.comment_todo()
"\n" main
:block_comment Comment comment
* block_comment
"BFHNTX" block_comment noeat call=comment_todo.comment_todo()
"*" maybe_end_block_comment
:maybe_end_block_comment Comment comment
* block_comment noeat
"/" main
################ strings ############################
:single_quoted Character string
* single_quoted
"'" main
"\\" single_quoted call=.escape() recolor=-1
"\n" error
:double_quoted String string
* double_quoted
"\"" main
"\\" double_quoted call=.escape() recolor=-1
"\n" error
:back_quoted BackQuoted string
* back_quoted
"`" main
################### operators #######################
:operator Operator
* main
:parentheses Control
* 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
################### numbers ####################
:float_no_period Number
* end_of_number noeat
"0-9" float_no_period
"eE" integer
:integer Number
* error noeat
"+-" unsigned
"0-9" unsigned_or_end
:unsigned Number
* error noeat
"0-9" unsigned_or_end
:unsigned_or_end Number
* end_of_number noeat
"0-9" unsigned_or_end
:end_of_number Number
* main noeat
"i" main # imaginary number suffix
:number0 Number
* end_of_number noeat
"xX" hex
"." 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" float
:hex Number
* main noeat
"0-9a-fA-F" hex
:float Number
* end_of_number noeat
"0-9" float
"." period_decimal recolor=-1
"eE" integer
################# keywords and identifiers ##########################
:keyword_or_identifier Ident
* identifier
"\p{Lu}\p{Lt}" exported_identifier recolor=-1
"\p{Ll}\p{Lo}\p{Pc}\p{Nl}" keyword_or_identifier2
:exported_identifier DefinedIdent
* exported_identifier
"\x01-/:-@[-^`{-\x7f" main noeat
:identifier Ident
* identifier
"\x01-/:-@[-^`{-\x7f" main noeat
:keyword_or_identifier2 Ident
* identifier
"\c" keyword_or_identifier2
"\x01-/:-@[-^`{-\x7f" main noeat hold strings
"_" keyword
"break" stmt
"default" label
"func" keyword
"interface" struct
"select" cond
"case" label
"defer" stmt
"go" keyword
"struct" struct
"else" cond
"goto" stmt
"package" stmt
"switch" cond
"const" stmt
"fallthrough" keyword
"if" cond
"range" loop
"type" struct
"continue" stmt
"for" loop
"import" stmt
"return" stmt
"var" stmt
"true" boolean
"false" boolean
"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
"map" type
"chan" 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 Builtin
* main noeat
:stmt Statement
* main noeat
:label Label
* main noeat
:struct Structure
* main noeat
:cond Conditional
* main noeat
:loop Loop
* main noeat
:boolean Boolean
* main noeat
########################## .subr escape START ######################################
.subr escape
:esc StringEscape string
* 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 StringEscape string
* esc_err noeat
"a-fA-F0-9" hex7
:hex7 StringEscape string
* esc_err noeat
"a-fA-F0-9" hex6
:hex6 StringEscape string
* esc_err noeat
"a-fA-F0-9" hex5
:hex5 StringEscape string
* esc_err noeat
"a-fA-F0-9" hex4
:hex4 StringEscape string
* esc_err noeat
"a-fA-F0-9" hex3
:hex3 StringEscape string
* esc_err noeat
"a-fA-F0-9" hex2
:hex2 StringEscape string
* esc_err noeat
"a-fA-F0-9" hex1
:hex1 StringEscape string
* esc_err noeat
"a-fA-F0-9" whatever return
:oct2 StringEscape string
* esc_err noeat
"0-7" oct1
:oct1 StringEscape string
* esc_err noeat
"0-7" whatever return
:esc_err Bad
* esc_err return
"\n" esc_err_newline noeat recolor=-2
:esc_err_newline Bad
* esc_err return noeat
.end
########################## .subr escape END ######################################
|