diff options
author | murphy <murphy@rubychan.de> | 2009-10-19 17:20:57 +0000 |
---|---|---|
committer | murphy <murphy@rubychan.de> | 2009-10-19 17:20:57 +0000 |
commit | 70b9baf4ad1487b67a343078cdc750203ac6c70d (patch) | |
tree | 16cc979d1ba5a8ecc234ca55a464ac6153fe7235 /lib/coderay/scanners/java.rb | |
parent | 3a23d30cfd1ce226572c05cbf4e8f8043545b512 (diff) | |
download | coderay-70b9baf4ad1487b67a343078cdc750203ac6c70d.tar.gz |
Updated Java scanner: Higlighting of keywords according to java.sun.com.
* added :reserved, :pre_constant, :exception classes for idents and keywords
* "threadsafe" isn't a Java keyword
Diffstat (limited to 'lib/coderay/scanners/java.rb')
-rw-r--r-- | lib/coderay/scanners/java.rb | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/lib/coderay/scanners/java.rb b/lib/coderay/scanners/java.rb index dd2c014..73a2dc5 100644 --- a/lib/coderay/scanners/java.rb +++ b/lib/coderay/scanners/java.rb @@ -7,30 +7,33 @@ module Scanners register_for :java helper :builtin_types - # TODO: Check this! + # http://java.sun.com/docs/books/tutorial/java/nutsandbolts/_keywords.html KEYWORDS = %w[ - break case catch continue default do else - false finally for if instanceof new null - return switch throw true try typeof while - debugger export import package + assert break case catch continue default do else + finally for if instanceof import new package + return switch throw try typeof while + debugger export ] - + RESERVED = %w[ const goto ] + CONSTANTS = %w[ false null true ] MAGIC_VARIABLES = %w[ this super ] TYPES = %w[ - boolean byte char class interface double enum float String int long short void - ] << '[]' + boolean byte char class double enum float int interface long + short void + ] << '[]' # String[] should be highlighted as a type DIRECTIVES = %w[ abstract extends final implements native private protected public - static strictfp synchronized threadsafe throws transient volatile + static strictfp synchronized throws transient volatile ] - # Reserved for future use. - IDENT_KIND = WordList.new(:ident). add(KEYWORDS, :keyword). + add(RESERVED, :reserved). + add(CONSTANTS, :pre_constant). add(MAGIC_VARIABLES, :local_variable). add(TYPES, :type). add(BuiltinTypes::List, :pre_type). + add(BuiltinTypes::List.select { |builtin| builtin[/(Error|Exception)$/] }, :exception). add(DIRECTIVES, :directive) ESCAPE = / [bfnrtv\n\\'"] | x[a-fA-F0-9]{1,2} | [0-7]{1,3} /x |