##// END OF EJS Templates
Replaced french word "anonyme" at app/views/wiki/annotate.rhtml with label_user_anonymous (#8994)....
Replaced french word "anonyme" at app/views/wiki/annotate.rhtml with label_user_anonymous (#8994). Contributed by Tom Rochette. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6409 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r4619:144ca23442a5
r6289:f6a43a61da1f
Show More
c.rb
203 lines | 5.3 KiB | text/x-ruby | RubyLexer
Jean-Philippe Lang
Added syntax highlightment for repository files (using CodeRay)....
r638 module CodeRay
module Scanners
class C < Scanner
Jean-Philippe Lang
Reverts r3014 (CodeRay back to 0.7.6)....
r2965 include Streamable
Jean-Philippe Lang
Upgrade CodeRay to 0.9.2 (#3359)....
r3478
register_for :c
file_extension 'c'
Jean-Philippe Lang
Added syntax highlightment for repository files (using CodeRay)....
r638
RESERVED_WORDS = [
Jean-Philippe Lang
Upgrade CodeRay to 0.9.2 (#3359)....
r3478 'asm', 'break', 'case', 'continue', 'default', 'do',
'else', 'enum', 'for', 'goto', 'if', 'return',
'sizeof', 'struct', 'switch', 'typedef', 'union', 'while',
'restrict', # added in C99
Jean-Philippe Lang
Added syntax highlightment for repository files (using CodeRay)....
r638 ]
PREDEFINED_TYPES = [
Jean-Philippe Lang
Upgrade CodeRay to 0.9.2 (#3359)....
r3478 'int', 'long', 'short', 'char',
Jean-Philippe Lang
Added syntax highlightment for repository files (using CodeRay)....
r638 'signed', 'unsigned', 'float', 'double',
Jean-Philippe Lang
Upgrade CodeRay to 0.9.2 (#3359)....
r3478 'bool', 'complex', # added in C99
Jean-Philippe Lang
Added syntax highlightment for repository files (using CodeRay)....
r638 ]
PREDEFINED_CONSTANTS = [
'EOF', 'NULL',
Jean-Philippe Lang
Upgrade CodeRay to 0.9.2 (#3359)....
r3478 'true', 'false', # added in C99
]
DIRECTIVES = [
'auto', 'extern', 'register', 'static', 'void',
'const', 'volatile', # added in C89
'inline', # added in C99
Jean-Philippe Lang
Added syntax highlightment for repository files (using CodeRay)....
r638 ]
IDENT_KIND = WordList.new(:ident).
add(RESERVED_WORDS, :reserved).
add(PREDEFINED_TYPES, :pre_type).
Jean-Philippe Lang
Upgrade CodeRay to 0.9.2 (#3359)....
r3478 add(DIRECTIVES, :directive).
Jean-Philippe Lang
Added syntax highlightment for repository files (using CodeRay)....
r638 add(PREDEFINED_CONSTANTS, :pre_constant)
Jean-Philippe Lang
Upgrade CodeRay to 0.9.2 (#3359)....
r3478 ESCAPE = / [rbfntv\n\\'"] | x[a-fA-F0-9]{1,2} | [0-7]{1,3} /x
Jean-Philippe Lang
Added syntax highlightment for repository files (using CodeRay)....
r638 UNICODE_ESCAPE = / u[a-fA-F0-9]{4} | U[a-fA-F0-9]{8} /x
def scan_tokens tokens, options
state = :initial
Jean-Philippe Lang
Upgrade CodeRay to 0.9.2 (#3359)....
r3478 label_expected = true
case_expected = false
label_expected_before_preproc_line = nil
in_preproc_line = false
Jean-Philippe Lang
Added syntax highlightment for repository files (using CodeRay)....
r638
until eos?
kind = nil
match = nil
case state
when :initial
Jean-Philippe Lang
Upgrade CodeRay to 0.9.2 (#3359)....
r3478 if match = scan(/ \s+ | \\\n /x)
if in_preproc_line && match != "\\\n" && match.index(?\n)
in_preproc_line = false
label_expected = label_expected_before_preproc_line
end
tokens << [match, :space]
next
Jean-Philippe Lang
Added syntax highlightment for repository files (using CodeRay)....
r638
elsif scan(%r! // [^\n\\]* (?: \\. [^\n\\]* )* | /\* (?: .*? \*/ | .* ) !mx)
kind = :comment
elsif match = scan(/ \# \s* if \s* 0 /x)
match << scan_until(/ ^\# (?:elif|else|endif) .*? $ | \z /xm) unless eos?
kind = :comment
Jean-Philippe Lang
Upgrade CodeRay to 0.9.2 (#3359)....
r3478 elsif match = scan(/ [-+*=<>?:;,!&^|()\[\]{}~%]+ | \/=? | \.(?!\d) /x)
label_expected = match =~ /[;\{\}]/
if case_expected
label_expected = true if match == ':'
case_expected = false
end
Jean-Philippe Lang
Added syntax highlightment for repository files (using CodeRay)....
r638 kind = :operator
elsif match = scan(/ [A-Za-z_][A-Za-z_0-9]* /x)
kind = IDENT_KIND[match]
Jean-Philippe Lang
Upgrade CodeRay to 0.9.2 (#3359)....
r3478 if kind == :ident && label_expected && !in_preproc_line && scan(/:(?!:)/)
Jean-Philippe Lang
Added syntax highlightment for repository files (using CodeRay)....
r638 kind = :label
Jean-Philippe Lang
Upgrade CodeRay to 0.9.2 (#3359)....
r3478 match << matched
else
label_expected = false
if kind == :reserved
case match
when 'case', 'default'
case_expected = true
end
end
Jean-Philippe Lang
Added syntax highlightment for repository files (using CodeRay)....
r638 end
Jean-Philippe Lang
Upgrade CodeRay to 0.9.2 (#3359)....
r3478 elsif scan(/\$/)
kind = :ident
Jean-Philippe Lang
Added syntax highlightment for repository files (using CodeRay)....
r638 elsif match = scan(/L?"/)
tokens << [:open, :string]
if match[0] == ?L
tokens << ['L', :modifier]
match = '"'
end
state = :string
kind = :delimiter
Jean-Philippe Lang
Upgrade CodeRay to 0.9.2 (#3359)....
r3478 elsif scan(/#[ \t]*(\w*)/)
kind = :preprocessor
in_preproc_line = true
label_expected_before_preproc_line = label_expected
Jean-Philippe Lang
Added syntax highlightment for repository files (using CodeRay)....
r638 state = :include_expected if self[1] == 'include'
elsif scan(/ L?' (?: [^\'\n\\] | \\ #{ESCAPE} )? '? /ox)
Jean-Philippe Lang
Upgrade CodeRay to 0.9.2 (#3359)....
r3478 label_expected = false
Jean-Philippe Lang
Added syntax highlightment for repository files (using CodeRay)....
r638 kind = :char
elsif scan(/0[xX][0-9A-Fa-f]+/)
Jean-Philippe Lang
Upgrade CodeRay to 0.9.2 (#3359)....
r3478 label_expected = false
Jean-Philippe Lang
Added syntax highlightment for repository files (using CodeRay)....
r638 kind = :hex
elsif scan(/(?:0[0-7]+)(?![89.eEfF])/)
Jean-Philippe Lang
Upgrade CodeRay to 0.9.2 (#3359)....
r3478 label_expected = false
Jean-Philippe Lang
Added syntax highlightment for repository files (using CodeRay)....
r638 kind = :oct
Jean-Philippe Lang
Upgrade CodeRay to 0.9.2 (#3359)....
r3478 elsif scan(/(?:\d+)(?![.eEfF])L?L?/)
label_expected = false
Jean-Philippe Lang
Added syntax highlightment for repository files (using CodeRay)....
r638 kind = :integer
elsif scan(/\d[fF]?|\d*\.\d+(?:[eE][+-]?\d+)?[fF]?|\d+[eE][+-]?\d+[fF]?/)
Jean-Philippe Lang
Upgrade CodeRay to 0.9.2 (#3359)....
r3478 label_expected = false
Jean-Philippe Lang
Added syntax highlightment for repository files (using CodeRay)....
r638 kind = :float
else
getch
kind = :error
end
when :string
if scan(/[^\\\n"]+/)
kind = :content
elsif scan(/"/)
tokens << ['"', :delimiter]
tokens << [:close, :string]
state = :initial
Jean-Philippe Lang
Upgrade CodeRay to 0.9.2 (#3359)....
r3478 label_expected = false
Jean-Philippe Lang
Added syntax highlightment for repository files (using CodeRay)....
r638 next
elsif scan(/ \\ (?: #{ESCAPE} | #{UNICODE_ESCAPE} ) /mox)
kind = :char
elsif scan(/ \\ | $ /x)
tokens << [:close, :string]
kind = :error
state = :initial
Jean-Philippe Lang
Upgrade CodeRay to 0.9.2 (#3359)....
r3478 label_expected = false
Jean-Philippe Lang
Added syntax highlightment for repository files (using CodeRay)....
r638 else
raise_inspect "else case \" reached; %p not handled." % peek(1), tokens
end
when :include_expected
Jean-Philippe Lang
Reverts r1476 that is no longer needed after r3582....
r3469 if scan(/<[^>\n]+>?|"[^"\n\\]*(?:\\.[^"\n\\]*)*"?/)
Jean-Philippe Lang
Added syntax highlightment for repository files (using CodeRay)....
r638 kind = :include
state = :initial
elsif match = scan(/\s+/)
kind = :space
state = :initial if match.index ?\n
else
Jean-Philippe Lang
Upgrade CodeRay to 0.9.2 (#3359)....
r3478 state = :initial
next
Jean-Philippe Lang
Added syntax highlightment for repository files (using CodeRay)....
r638
end
else
raise_inspect 'Unknown state', tokens
end
match ||= matched
Jean-Philippe Lang
Upgrade CodeRay to 0.9.2 (#3359)....
r3478 if $CODERAY_DEBUG and not kind
Jean-Philippe Lang
Added syntax highlightment for repository files (using CodeRay)....
r638 raise_inspect 'Error token %p in line %d' %
[[match, kind], line], tokens
end
raise_inspect 'Empty token', tokens unless match
tokens << [match, kind]
end
if state == :string
tokens << [:close, :string]
end
tokens
end
end
end
end