diff options
author | murphy <murphy@rubychan.de> | 2009-04-14 04:12:12 +0000 |
---|---|---|
committer | murphy <murphy@rubychan.de> | 2009-04-14 04:12:12 +0000 |
commit | 078ea65a5deb2c1ee6c4b982a20856e2d186536d (patch) | |
tree | fc3e18755b763e618c01a4436b5ecff05913c319 | |
parent | 8da37c556981eb83f9ca1b61e38a6672e4c198aa (diff) | |
download | coderay-078ea65a5deb2c1ee6c4b982a20856e2d186536d.tar.gz |
Java scanner:
* Fixed test after r305 broke it.
* [FIXED] Save last_token_dot state through comments.
C scanner:
* Added file_extension declaration.
** All scanners should have this.
* Code cleanup.
-rw-r--r-- | lib/coderay/scanners/c.rb | 5 | ||||
-rw-r--r-- | lib/coderay/scanners/java.rb | 7 | ||||
-rw-r--r-- | test/scanners/java/jruby.expected.raydebug | 14 |
3 files changed, 14 insertions, 12 deletions
diff --git a/lib/coderay/scanners/c.rb b/lib/coderay/scanners/c.rb index f6d71ad..9ec81ce 100644 --- a/lib/coderay/scanners/c.rb +++ b/lib/coderay/scanners/c.rb @@ -3,9 +3,10 @@ module Scanners class C < Scanner - register_for :c - include Streamable + + register_for :c + file_extension 'c' RESERVED_WORDS = [ 'asm', 'break', 'case', 'continue', 'default', 'do', 'else', diff --git a/lib/coderay/scanners/java.rb b/lib/coderay/scanners/java.rb index 71ad31a..dd2c014 100644 --- a/lib/coderay/scanners/java.rb +++ b/lib/coderay/scanners/java.rb @@ -61,8 +61,9 @@ module Scanners tokens << [match, :space] next - elsif scan(%r! // [^\n\\]* (?: \\. [^\n\\]* )* | /\* (?: .*? \*/ | .* ) !mx) - kind = :comment + elsif match = scan(%r! // [^\n\\]* (?: \\. [^\n\\]* )* | /\* (?: .*? \*/ | .* ) !mx) + tokens << [match, :comment] + next elsif import_clause && scan(/ #{IDENT} (?: \. #{IDENT} )* /ox) kind = :include @@ -79,7 +80,7 @@ module Scanners class_name_follows = true if match == 'class' || match == 'interface' end - elsif scan(/ \.(?!\d) | [,?:(\[)\]}] | -- | \+\+ | && | \|\| | \*\*=? | [-+*\/%^~&|<>=!]=? | <<<?=? | >>>?=? /x) + elsif scan(/ \.(?!\d) | [,?:()\[\]}] | -- | \+\+ | && | \|\| | \*\*=? | [-+*\/%^~&|<>=!]=? | <<<?=? | >>>?=? /x) kind = :operator elsif scan(/;/) diff --git a/test/scanners/java/jruby.expected.raydebug b/test/scanners/java/jruby.expected.raydebug index 525bd39..86da6c0 100644 --- a/test/scanners/java/jruby.expected.raydebug +++ b/test/scanners/java/jruby.expected.raydebug @@ -50,7 +50,7 @@ comment(/** * @author pldms * */) -directive(public) type(interface) ident(Finalizable) operator({) +directive(public) type(interface) class(Finalizable) operator({) directive(public) type(void) ident(finalize)operator(()operator(\))operator(;) operator(}) comment(/***** BEGIN LICENSE BLOCK ***** @@ -91,7 +91,7 @@ comment(/** * The purpose of this class it to help implement the Errno module which in turn in needed by rubicon. * @author Benoit Cerrina **/) -directive(public) type(interface) ident(IErrno) +directive(public) type(interface) class(IErrno) operator({) type(int) ident(EPERM) operator(=) integer(1)operator(;) type(int) ident(ENOENT) operator(=) integer(2)operator(;) @@ -590,7 +590,7 @@ directive(public) type(class) class(JRubyApplet) directive(extends) pre_type(App directive(private) pre_type(Graphics) ident(backBufferGraphics)operator(;) directive(private) ident(Facade) ident(facade)operator(;) - directive(private) type(interface) ident(Facade) operator({) + directive(private) type(interface) class(Facade) operator({) directive(public) pre_type(InputStream) ident(getInputStream)operator(()operator(\))operator(;) directive(public) pre_type(PrintStream) ident(getOutputStream)operator(()operator(\))operator(;) directive(public) pre_type(PrintStream) ident(getErrorStream)operator(()operator(\))operator(;) @@ -1742,7 +1742,7 @@ keyword(package) ident(org)operator(.)ident(jruby)operator(;) comment(/** * @author <a href="mailto:ola.bini@ki.se">Ola Bini</a> */) -directive(public) type(interface) ident(Profile) operator({) +directive(public) type(interface) class(Profile) operator({) ident(Profile) ident(ALL) operator(=) keyword(new) ident(Profile)operator(()operator(\)) operator({) directive(public) type(boolean) ident(allowBuiltin)operator(()pre_type(String) ident(name)operator(\)) operator({) keyword(return) keyword(true)operator(;) operator(}) directive(public) type(boolean) ident(allowClass)operator(()pre_type(String) ident(name)operator(\)) operator({) keyword(return) keyword(true)operator(;) operator(}) @@ -21557,7 +21557,7 @@ directive(public) type(class) class(RubyInstanceConfig) operator({) directive(public) directive(static) type(boolean) ident(nativeEnabled) operator(=) keyword(true)operator(;) - directive(public) directive(static) type(interface) ident(LoadServiceCreator) operator({) + directive(public) directive(static) type(interface) class(LoadServiceCreator) operator({) ident(LoadService) ident(create)operator(()ident(Ruby) ident(runtime)operator(\))operator(;) ident(LoadServiceCreator) ident(DEFAULT) operator(=) keyword(new) ident(LoadServiceCreator)operator(()operator(\)) operator({) @@ -36946,7 +36946,7 @@ comment(/** * * @author nicksieger */) -directive(public) type(interface) ident(RubyObjectAdapter) operator({) +directive(public) type(interface) class(RubyObjectAdapter) operator({) type(boolean) ident(isKindOf)operator(()ident(IRubyObject) ident(value)operator(,) ident(RubyModule) ident(rubyModule)operator(\))operator(;) @@ -40779,7 +40779,7 @@ comment(/** * * @author nicksieger */) -directive(public) type(interface) ident(RubyRuntimeAdapter) operator({) +directive(public) type(interface) class(RubyRuntimeAdapter) operator({) ident(IRubyObject) ident(eval)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(String) ident(script)operator(\))operator(;) operator(}) comment(/***** BEGIN LICENSE BLOCK ***** |