1
0
mirror of https://github.com/cmur2/joe-syntax.git synced 2024-12-22 02:54:23 +01:00

after_term support for Javascript highlighter

This allows us to parse / / regex literals correctly in (nearly?) all
situations by recognizing if a literal is currently allowed or not (after terms!).

Now calc(a / b) works perfectly since 'a' is a term.
But match(/blub/) works too since after a ( everything is allowed.

Tested on JQuery 1.6.2 normal source ;-)
This commit is contained in:
Christian Nicolai 2011-08-06 12:32:37 +02:00
parent 5b54f69666
commit 0ca5a95d56

75
js.jsf
View File

@ -5,11 +5,6 @@
# TODO: regex escape highlighter ignored \x (and other?) sequences # TODO: regex escape highlighter ignored \x (and other?) sequences
# BUG: The regex has currently some SERIOUS problems - enabled
# or disabled: calc(a / b) vs match(/'/) - one of the two fails,
# need "after_term" support like in ruby.jsf
=Idle =Idle
=Comment green =Comment green
=CommentLabel bold green =CommentLabel bold green
@ -18,9 +13,9 @@
=Type bold =Type bold
=Keyword bold =Keyword bold
=Operator bold =Operator bold
=Bad bold red =Bad inverse bold red
=Brace magenta =Brace magenta
=Control =Control
# additional classes not present everywhere but useful # additional classes not present everywhere but useful
=Methods =Methods
@ -37,7 +32,14 @@
"'" char recolor=-1 "'" char recolor=-1
"a-zA-Z_" ident mark buffer "a-zA-Z_" ident mark buffer
"{}" brace recolor=-1 "{}" brace recolor=-1
",:;=()><[]*&|!~+\-%^" control recolor=-1 ",:;=()><[]*&|!?~+\-%^" control recolor=-1
# / / regex not allowed after terms
# class Control to handle ')' right
:after_term Control
* idle noeat
" \t)" after_term
"%/" control recolor=-1
:brace Brace :brace Brace
* idle noeat * idle noeat
@ -46,10 +48,7 @@
* idle noeat * idle noeat
:slash Idle :slash Idle
* idle noeat * regex noeat recolor=-2
# the "noeat recolor=-2" is needed since _this_ char maybe '\'
# * regex noeat recolor=-2
"*" comment recolor=-2 "*" comment recolor=-2
"/" line_comment recolor=-2 "/" line_comment recolor=-2
@ -70,20 +69,20 @@
"BFHNTX" line_comment noeat call=.comment_todo() "BFHNTX" line_comment noeat call=.comment_todo()
"\n" idle "\n" idle
#:regex Constant :regex Constant
# * regex * regex
# "\\" regex_esc recolor=-1 "\\" regex_quote recolor=-1
# "/" regex_mod "/" regex_mod
#
#:regex_esc Escape :regex_quote Escape
# * regex * regex
#
#:regex_mod Constant :regex_mod Constant
# * idle noeat * after_term noeat
# "igm" regex_mod "igm" regex_mod
:first_digit Number :first_digit Number
* idle noeat * after_term noeat
"xX" hex "xX" hex
"." float "." float
"eE" epart "eE" epart
@ -91,44 +90,44 @@
"89" bad_number recolor=-1 "89" bad_number recolor=-1
:bad_number Bad :bad_number Bad
* idle noeat * after_term noeat
"0-9" bad_number "0-9" bad_number
:octal Number :octal Number
* idle noeat * after_term noeat
"0-7" octal "0-7" octal
"89" bad_number recolor=-1 "89" bad_number recolor=-1
:hex Number :hex Number
* idle noeat * after_term noeat
"0-9A-Fa-f" hex "0-9A-Fa-f" hex
:decimal Number :decimal Number
* idle noeat * after_term noeat
"0-9" decimal "0-9" decimal
"eE" epart "eE" epart
"." float "." float
:maybe_float Number :maybe_float Number
* idle recolor=-2 noeat * after_term recolor=-2 noeat
"0-9" float recolor=-2 "0-9" float recolor=-2
:float Number :float Number
* idle noeat * after_term noeat
"eE" epart "eE" epart
"0-9" float "0-9" float
:epart Number :epart Number
* idle noeat * after_term noeat
"0-9+\-" enum "0-9+\-" enum
:enum Number :enum Number
* idle noeat * after_term noeat
"0-9" enum "0-9" enum
:string Constant :string Constant
* string * string
"\"" idle "\"" after_term
"\\" string_escape recolor=-1 "\\" string_escape recolor=-1
"%" string_control recolor=-1 "%" string_control recolor=-1
@ -162,7 +161,7 @@
:char Constant :char Constant
* char * char
"\n" reset "\n" reset
"'" idle "'" after_term
"\\" char_escape recolor=-1 "\\" char_escape recolor=-1
:char_escape Escape :char_escape Escape
@ -228,23 +227,25 @@
"void" kw "void" kw
"while" kw "while" kw
"with" kw "with" kw
# quasi-keywords
"prototype" kw
done done
"a-zA-Z0-9_" ident "a-zA-Z0-9_" ident
:type Type :type Type
* idle noeat * after_term noeat
:kw Keyword :kw Keyword
* idle noeat * idle noeat
:lit Constant :lit Constant
* idle noeat * after_term noeat
:operator Operator :operator Operator
* idle noeat * idle noeat
:ident_end Idle :ident_end Idle
* idle noeat * after_term noeat
" " ident_end " " ident_end
"(" method_end noeat recolormark "(" method_end noeat recolormark