diff options
author | murphy <murphy@rubychan.de> | 2011-04-17 14:03:02 +0000 |
---|---|---|
committer | murphy <murphy@rubychan.de> | 2011-04-17 14:03:02 +0000 |
commit | d8c9161dc174e364fc4a3e8e9df1d45262c5cc4a (patch) | |
tree | 0f079cd03bb4fb43c36ee5c161b210c7a9cbd189 | |
parent | 84bbaddb495a1657433106a85274424e5a56259e (diff) | |
download | coderay-d8c9161dc174e364fc4a3e8e9df1d45262c5cc4a.tar.gz |
renamed pre_* token kinds to predefined_*
-rw-r--r-- | Changes.textile | 1 | ||||
-rw-r--r-- | lib/coderay/encoders/html.rb | 8 | ||||
-rw-r--r-- | lib/coderay/encoders/html/output.rb | 6 | ||||
-rw-r--r-- | lib/coderay/encoders/terminal.rb | 4 | ||||
-rw-r--r-- | lib/coderay/helpers/word_list.rb | 4 | ||||
-rw-r--r-- | lib/coderay/scanners/c.rb | 4 | ||||
-rw-r--r-- | lib/coderay/scanners/clojure.rb | 4 | ||||
-rw-r--r-- | lib/coderay/scanners/cpp.rb | 4 | ||||
-rw-r--r-- | lib/coderay/scanners/java.rb | 4 | ||||
-rw-r--r-- | lib/coderay/scanners/java_script.rb | 2 | ||||
-rw-r--r-- | lib/coderay/scanners/php.rb | 6 | ||||
-rw-r--r-- | lib/coderay/scanners/python.rb | 2 | ||||
-rw-r--r-- | lib/coderay/scanners/ruby/patterns.rb | 2 | ||||
-rw-r--r-- | lib/coderay/scanners/scheme.rb | 2 | ||||
-rw-r--r-- | lib/coderay/scanners/sql.rb | 6 | ||||
-rwxr-xr-x | lib/coderay/token_kinds.rb | 4 | ||||
-rw-r--r-- | test/unit/word_list.rb | 8 |
17 files changed, 33 insertions, 38 deletions
diff --git a/Changes.textile b/Changes.textile index 6a833bb..1b69143 100644 --- a/Changes.textile +++ b/Changes.textile @@ -53,6 +53,7 @@ Renamed from @Tokens::ClassOfKind@ (was also @Tokens::AbbreviationForKind@ for a The term "token class" is no longer used in CodeRay. Instead, tokens have _kinds_. See "#122":http://redmine.rubychan.de/issues/122. +* *RENAMED* @:pre_constant@ and @:pre_type@ to @:predefined_constant@ and @predefined_type@. * *REMOVED* token kinds @:attribute_name_fat@, @:attribute_value_fat@, @:operator_fat@, @:tag_fat@, @:xml_text@, @:nesting_delimiter@, @:open@, and @:close@. * *ADDED* token kinds @:filename@, @:namespace@, and @:eyecatcher@. diff --git a/lib/coderay/encoders/html.rb b/lib/coderay/encoders/html.rb index 4c5695d..d6dfb9e 100644 --- a/lib/coderay/encoders/html.rb +++ b/lib/coderay/encoders/html.rb @@ -136,13 +136,7 @@ module Encoders HTML_ESCAPE_PATTERN = /[\t"&><\0-\x8\xB-\x1f]/ TOKEN_KIND_TO_INFO = Hash.new do |h, kind| - h[kind] = - case kind - when :pre_constant # FIXME: rename to :predefined_constant - 'Predefined constant' - else - kind.to_s.gsub(/_/, ' ').gsub(/\b\w/) { $&.capitalize } - end + h[kind] = kind.to_s.gsub(/_/, ' ').gsub(/\b\w/) { $&.capitalize } end TRANSPARENT_TOKEN_KINDS = Set[ diff --git a/lib/coderay/encoders/html/output.rb b/lib/coderay/encoders/html/output.rb index 40e3b04..5aa80a7 100644 --- a/lib/coderay/encoders/html/output.rb +++ b/lib/coderay/encoders/html/output.rb @@ -3,14 +3,14 @@ module Encoders class HTML - # This module is included in the output String from thew HTML Encoder. + # This module is included in the output String of the HTML Encoder. # # It provides methods like wrap, div, page etc. # # Remember to use #clone instead of #dup to keep the modules the object was # extended with. # - # TODO: more doc. + # TODO: Rewrite this without monkey patching. module Output attr_accessor :css @@ -25,7 +25,7 @@ module Encoders def make_stylesheet css, in_tag = false # :nodoc: sheet = css.stylesheet - sheet = <<-CSS if in_tag + sheet = <<-'CSS' if in_tag <style type="text/css"> #{sheet} </style> diff --git a/lib/coderay/encoders/terminal.rb b/lib/coderay/encoders/terminal.rb index 4d64aba..860ea9c 100644 --- a/lib/coderay/encoders/terminal.rb +++ b/lib/coderay/encoders/terminal.rb @@ -53,8 +53,8 @@ module CodeRay :local_variable => '33', :oct => '1;35', :operator_name => '1;29', - :pre_constant => '1;36', - :pre_type => '1;30', + :predefined_constant => '1;36', + :predefined_type => '1;30', :predefined => ['4', '1;34'], :preprocessor => '36', :pseudo_class => '34', diff --git a/lib/coderay/helpers/word_list.rb b/lib/coderay/helpers/word_list.rb index 9b4f456..3af52cf 100644 --- a/lib/coderay/helpers/word_list.rb +++ b/lib/coderay/helpers/word_list.rb @@ -37,8 +37,8 @@ module CodeRay # # make a WordList # IDENT_KIND = WordList.new(:ident). # add(RESERVED_WORDS, :reserved). -# add(PREDEFINED_TYPES, :pre_type). -# add(PREDEFINED_CONSTANTS, :pre_constant) +# add(PREDEFINED_TYPES, :predefined_type). +# add(PREDEFINED_CONSTANTS, :predefined_constant) # # ... # diff --git a/lib/coderay/scanners/c.rb b/lib/coderay/scanners/c.rb index 9f33074..03bc1b9 100644 --- a/lib/coderay/scanners/c.rb +++ b/lib/coderay/scanners/c.rb @@ -32,9 +32,9 @@ module Scanners IDENT_KIND = WordList.new(:ident). add(RESERVED_WORDS, :reserved). - add(PREDEFINED_TYPES, :pre_type). + add(PREDEFINED_TYPES, :predefined_type). add(DIRECTIVES, :directive). - add(PREDEFINED_CONSTANTS, :pre_constant) # :nodoc: + add(PREDEFINED_CONSTANTS, :predefined_constant) # :nodoc: ESCAPE = / [rbfntv\n\\'"] | x[a-fA-F0-9]{1,2} | [0-7]{1,3} /x # :nodoc: UNICODE_ESCAPE = / u[a-fA-F0-9]{4} | U[a-fA-F0-9]{8} /x # :nodoc: diff --git a/lib/coderay/scanners/clojure.rb b/lib/coderay/scanners/clojure.rb index a16abdc..4d7ff3e 100644 --- a/lib/coderay/scanners/clojure.rb +++ b/lib/coderay/scanners/clojure.rb @@ -84,7 +84,7 @@ module CodeRay IDENT_KIND = CaseIgnoringWordList.new(:ident). add(SPECIAL_FORMS, :reserved). add(CORE_FORMS, :reserved). - add(PREDEFINED_CONSTANTS, :pre_constant) + add(PREDEFINED_CONSTANTS, :predefined_constant) BASIC_IDENTIFIER = /[a-zA-Z$%*\/_+!?&<>\-=][a-zA-Z0-9$&*+!\/_?<>\-\#]*/ IDENTIFIER = /(?:[@']?(?:#{BASIC_IDENTIFIER}\.)*#{BASIC_IDENTIFIER}(?:\/#{BASIC_IDENTIFIER})?\.?)|\.\.?/ @@ -154,7 +154,7 @@ module CodeRay elsif match = scan(/\#\\(?:newline|space|.?)/) encoder.text_token match, :char elsif match = scan(/\#[ft]/) - encoder.text_token match, :pre_constant + encoder.text_token match, :predefined_constant elsif match = scan(/#{IDENTIFIER}/o) encoder.text_token match, ident_kind[matched] elsif match = scan(/#{SYMBOL}/o) diff --git a/lib/coderay/scanners/cpp.rb b/lib/coderay/scanners/cpp.rb index cb79768..10b4c04 100644 --- a/lib/coderay/scanners/cpp.rb +++ b/lib/coderay/scanners/cpp.rb @@ -41,10 +41,10 @@ module Scanners IDENT_KIND = WordList.new(:ident). add(RESERVED_WORDS, :reserved). - add(PREDEFINED_TYPES, :pre_type). + add(PREDEFINED_TYPES, :predefined_type). add(PREDEFINED_VARIABLES, :local_variable). add(DIRECTIVES, :directive). - add(PREDEFINED_CONSTANTS, :pre_constant) # :nodoc: + add(PREDEFINED_CONSTANTS, :predefined_constant) # :nodoc: ESCAPE = / [rbfntv\n\\'"] | x[a-fA-F0-9]{1,2} | [0-7]{1,3} /x # :nodoc: UNICODE_ESCAPE = / u[a-fA-F0-9]{4} | U[a-fA-F0-9]{8} /x # :nodoc: diff --git a/lib/coderay/scanners/java.rb b/lib/coderay/scanners/java.rb index ef3d8f8..0ad8a41 100644 --- a/lib/coderay/scanners/java.rb +++ b/lib/coderay/scanners/java.rb @@ -30,10 +30,10 @@ module Scanners IDENT_KIND = WordList.new(:ident). add(KEYWORDS, :keyword). add(RESERVED, :reserved). - add(CONSTANTS, :pre_constant). + add(CONSTANTS, :predefined_constant). add(MAGIC_VARIABLES, :local_variable). add(TYPES, :type). - add(BuiltinTypes::List, :pre_type). + add(BuiltinTypes::List, :predefined_type). add(BuiltinTypes::List.select { |builtin| builtin[/(Error|Exception)$/] }, :exception). add(DIRECTIVES, :directive) # :nodoc: diff --git a/lib/coderay/scanners/java_script.rb b/lib/coderay/scanners/java_script.rb index 68bf786..9ebda6f 100644 --- a/lib/coderay/scanners/java_script.rb +++ b/lib/coderay/scanners/java_script.rb @@ -35,7 +35,7 @@ module Scanners IDENT_KIND = WordList.new(:ident). add(RESERVED_WORDS, :reserved). - add(PREDEFINED_CONSTANTS, :pre_constant). + add(PREDEFINED_CONSTANTS, :predefined_constant). add(MAGIC_VARIABLES, :local_variable). add(KEYWORDS, :keyword) # :nodoc: diff --git a/lib/coderay/scanners/php.rb b/lib/coderay/scanners/php.rb index 7f09de9..ed1095e 100644 --- a/lib/coderay/scanners/php.rb +++ b/lib/coderay/scanners/php.rb @@ -183,12 +183,12 @@ module Scanners IDENT_KIND = CaseIgnoringWordList.new(:ident). add(KEYWORDS, :reserved). - add(TYPES, :pre_type). + add(TYPES, :predefined_type). add(LANGUAGE_CONSTRUCTS, :reserved). add(BUILTIN_FUNCTIONS, :predefined). - add(CLASSES, :pre_constant). + add(CLASSES, :predefined_constant). add(EXCEPTIONS, :exception). - add(CONSTANTS, :pre_constant) + add(CONSTANTS, :predefined_constant) VARIABLE_KIND = WordList.new(:local_variable). add(PREDEFINED, :predefined) diff --git a/lib/coderay/scanners/python.rb b/lib/coderay/scanners/python.rb index 56b9ae6..f0504c7 100644 --- a/lib/coderay/scanners/python.rb +++ b/lib/coderay/scanners/python.rb @@ -58,7 +58,7 @@ module Scanners add(KEYWORDS, :keyword). add(OLD_KEYWORDS, :old_keyword). add(PREDEFINED_METHODS_AND_TYPES, :predefined). - add(PREDEFINED_VARIABLES_AND_CONSTANTS, :pre_constant). + add(PREDEFINED_VARIABLES_AND_CONSTANTS, :predefined_constant). add(PREDEFINED_EXCEPTIONS, :exception) # :nodoc: NAME = / [^\W\d] \w* /x # :nodoc: diff --git a/lib/coderay/scanners/ruby/patterns.rb b/lib/coderay/scanners/ruby/patterns.rb index 9effc9a..5acb25e 100644 --- a/lib/coderay/scanners/ruby/patterns.rb +++ b/lib/coderay/scanners/ruby/patterns.rb @@ -27,7 +27,7 @@ module Scanners IDENT_KIND = WordList.new(:ident). add(RESERVED_WORDS, :reserved). - add(PREDEFINED_CONSTANTS, :pre_constant) + add(PREDEFINED_CONSTANTS, :predefined_constant) KEYWORD_NEW_STATE = WordList.new(:initial). add(%w[ def ], :def_expected). diff --git a/lib/coderay/scanners/scheme.rb b/lib/coderay/scanners/scheme.rb index c29641e..e2c36e6 100644 --- a/lib/coderay/scanners/scheme.rb +++ b/lib/coderay/scanners/scheme.rb @@ -90,7 +90,7 @@ module CodeRay elsif match = scan(/#\\(?:newline|space|.?)/) encoder.text_token match, :char elsif match = scan(/#[ft]/) - encoder.text_token match, :pre_constant + encoder.text_token match, :predefined_constant elsif match = scan(/#{IDENTIFIER}/o) encoder.text_token match, ident_kind[matched] elsif match = scan(/\./) diff --git a/lib/coderay/scanners/sql.rb b/lib/coderay/scanners/sql.rb index effaa94..392866e 100644 --- a/lib/coderay/scanners/sql.rb +++ b/lib/coderay/scanners/sql.rb @@ -41,8 +41,8 @@ module CodeRay module Scanners add(RESERVED_WORDS, :reserved). add(OBJECTS, :type). add(COMMANDS, :class). - add(PREDEFINED_TYPES, :pre_type). - add(PREDEFINED_CONSTANTS, :pre_constant). + add(PREDEFINED_TYPES, :predefined_type). + add(PREDEFINED_CONSTANTS, :predefined_constant). add(PREDEFINED_FUNCTIONS, :predefined). add(DIRECTIVES, :directive) @@ -99,7 +99,7 @@ module CodeRay module Scanners encoder.text_token match, :float elsif match = scan(/\\N/) - encoder.text_token match, :pre_constant + encoder.text_token match, :predefined_constant else encoder.text_token getch, :error diff --git a/lib/coderay/token_kinds.rb b/lib/coderay/token_kinds.rb index 1a8f85f..45507a1 100755 --- a/lib/coderay/token_kinds.rb +++ b/lib/coderay/token_kinds.rb @@ -55,8 +55,8 @@ module CodeRay :oct => 'oc', :predefined => 'pd', :preprocessor => 'pp', - :pre_constant => 'pc', # FIXME: rename to :predefined_constant - :pre_type => 'pt', # FIXME: rename to :predefined_type + :predefined_constant => 'pc', + :predefined_type => 'pt', :pseudo_class => 'ps', :regexp => 'rx', :reserved => 'r', diff --git a/test/unit/word_list.rb b/test/unit/word_list.rb index 449c9dc..803e268 100644 --- a/test/unit/word_list.rb +++ b/test/unit/word_list.rb @@ -23,12 +23,12 @@ class WordListTest < Test::Unit::TestCase # make a WordList IDENT_KIND = WordList.new(:ident). add(RESERVED_WORDS, :reserved). - add(PREDEFINED_TYPES, :pre_type). - add(PREDEFINED_CONSTANTS, :pre_constant) + add(PREDEFINED_TYPES, :predefined_type). + add(PREDEFINED_CONSTANTS, :predefined_constant) def test_word_list_example - assert_equal :pre_type, IDENT_KIND['void'] - # assert_equal :pre_constant, IDENT_KIND['...'] # not specified + assert_equal :predefined_type, IDENT_KIND['void'] + # assert_equal :predefined_constant, IDENT_KIND['...'] # not specified end def test_word_list |