1
0
mirror of https://github.com/cmur2/joe-syntax.git synced 2024-11-14 16:56:15 +01:00
joe-syntax/python.jsf

291 lines
4.8 KiB
Plaintext
Raw Normal View History

# JOE syntax highlight file for Python
=Idle
=Comment green
=Docstring green
=DocstringLabel bold green
=DocEscape bold cyan
=Constant cyan
=Escape bold cyan
=Keyword bold
2011-09-03 11:05:07 +02:00
=Bad bold red
=Brace magenta
=PrivateMember yellow #fg_310 # brown
=Decorator red
2015-03-03 14:16:53 +01:00
=Declaration bold blue
:idle Idle
* idle
"#" comment recolor=-1
"0-9" first_digit recolor=-1
2015-03-03 14:16:53 +01:00
"'\"" string_quot_1 recolor=-1 save_c
"a-zA-Z_" ident noeat
2011-09-03 11:05:07 +02:00
"{}" brace recolor=-1
"@" decorator recolor=-1
2011-09-03 11:05:07 +02:00
:brace Brace
* idle noeat
# annotations
:decorator Decorator
* decorator
" (\t\r\n" idle noeat
:comment Comment
* comment
2011-09-03 11:05:07 +02:00
# might be TODO label
2015-03-03 14:16:53 +01:00
"BFHNTX" comment noeat call=comment_todo.comment_todo()
"\n" idle
:first_digit Constant
2015-03-03 14:16:53 +01:00
* idle noeat
"xX" hex
"." float
2015-03-03 14:16:53 +01:00
"eE" epart
"0-9" first_number
:hex Constant
2015-03-03 14:16:53 +01:00
* idle noeat
"0-9A-Fa-f" hex
:first_number Constant
2015-03-03 14:16:53 +01:00
* idle noeat
"0-9" first_number
"." float
:maybe_float Constant
2015-03-03 14:16:53 +01:00
* idle recolor=-2 noeat
"0-9" float recolor=-2
:float Constant
2015-03-03 14:16:53 +01:00
* idle noeat
"eE" epart
"0-9" float
:epart Constant
2015-03-03 14:16:53 +01:00
* idle noeat
"0-9+\-" enum
:enum Constant
2015-03-03 14:16:53 +01:00
* idle noeat
"0-9" enum
:ident Idle
* ident1 noeat buffer
"_" priv_member recolor=-1
:ident1 Idle
* idle noeat strings
"and" kw
2015-03-03 14:16:53 +01:00
"as" kw
"assert" kw
"break" kw
2015-03-03 14:16:53 +01:00
"class" declkw
"continue" kw
2015-03-03 14:16:53 +01:00
"def" declkw
"del" kw
"elif" kw
"else" kw
"except" kw
"exec" kw
"finally" kw
"for" kw
"from" kw
"global" kw
"if" kw
"import" kw
"in" kw
"is" kw
"lambda" kw
"not" kw
"or" kw
"pass" kw
"print" kw
"raise" kw
"return" kw
"try" kw
"while" kw
2015-03-03 14:16:53 +01:00
"with" kw
"yield" kw
2015-03-03 14:16:53 +01:00
# quasi-keywords
"False" lit
"None" lit
"True" lit
2015-03-03 14:16:53 +01:00
done
"'\"" idle noeat istrings
"u" string_pre
"b" string_pre
"r" string_raw_pre
"br" string_raw_pre
"rb" string_raw_pre
done
"a-zA-Z0-9_" ident1
:kw Keyword
* idle noeat
:lit Keyword
* idle noeat
2011-09-03 11:05:07 +02:00
2015-03-03 14:16:53 +01:00
:declkw Keyword
* idle noeat recolor=-1
"a-zA-Z" declkw
" \t" declname_1
:declname_1 Declaration
* declname
"_" priv_member recolor=-1
:declname Declaration
* idle noeat recolor=-1
"a-zA-Z0-9_" declname
:priv_member PrivateMember
* idle noeat
"a-zA-Z0-9_" priv_member
2015-03-03 14:16:53 +01:00
# Handle string prefixes up to the string itself.
:string_pre Constant
* idle noeat
"'\"" string_quot_1 save_c
:string_raw_pre Constant
* idle noeat
"'\"" string_quot_raw_1 save_c
# Differentiate between docstrings and regular strings, carrying with it raw state
:string_quot_1 Constant
* idle call=.string() noeat
& string_quot_2
:string_quot_2 Constant
* idle noeat
& idle call=.string(docstring) recolor=-3
:string_quot_raw_1 Constant
* idle call=.string(raw)
& string_quot_raw_2
:string_quot_raw_2 Constant
* idle noeat
& idle call=.string(docstring raw) recolor=-3
.subr string
.ifdef docstring # Long strings
:string Docstring
* string
"BFHNTX" string noeat call=.comment_todo_docstr()
.ifdef raw
.else
"\\" string_esc mark
.endif
& doc_end_1
:doc_end_1 Docstring
* string noeat
& doc_end_2
:doc_end_2 Docstring
* string noeat
& string return
.else # Short strings
:string Constant
* string
"\n" string return
.ifdef raw
.else
"\\" string_esc mark
.endif
& string return
.endif
:string_esc Constant
* string_esc_done
"x" string_hex2
"u" string_hex4
"U" string_hex8
"0-7" string_octal2
"\n" string_esc_done
# Recolor whole escape sequence based on whether this is a docstring.
:string_esc_done Constant
* string_esc_really_done noeat markend recolormark
.ifdef docstring
:string_esc_really_done DocEscape
* string noeat
.else
:string_esc_really_done Escape
* string noeat
.endif
:string_hex1 Escape
* string_esc_done noeat
"0-9a-fA-F" string_esc_done
:string_hex2 Escape
* string_esc_done noeat
"0-9a-fA-F" string_hex1
:string_hex3 Escape
* string_esc_done noeat
"0-9a-fA-F" string_hex2
:string_hex4 Escape
* string_esc_done noeat
"0-9a-fA-F" string_hex3
:string_hex5 Escape
* string_esc_done noeat
"0-9a-fA-F" string_hex4
:string_hex6 Escape
* string_esc_done noeat
"0-9a-fA-F" string_hex5
:string_hex7 Escape
* string_esc_done noeat
"0-9a-fA-F" string_hex6
:string_hex8 Escape
* string_esc_done noeat
"0-9a-fA-F" string_hex7
:string_octal1 Escape
* string_esc_done noeat
"0-7" string_esc_done
:string_octal2 Escape
* string_esc_done noeat
"0-7" string_octal1
2011-09-03 11:05:07 +02:00
.subr comment_todo_docstr
# initial state
:comment_todo_init Docstring
* comment_todo_guess buffer
# highlight common TODO labels
:comment_todo_guess Docstring
* comment_todo_unknown noeat strings
"BUG" comment_todo
"FIXME" comment_todo
"HACK" comment_todo
"NOTE" comment_todo
"TODO" comment_todo
"XXX" comment_todo
done
"A-Z" comment_todo_guess
:comment_todo_unknown Docstring
* NULL noeat return
:comment_todo DocstringLabel
* NULL noeat return
.end