Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions lib/coderay/scanners/c.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ def scan_tokens encoder, options
end
encoder.text_token match, :operator

elsif match = scan(/L?"/)
encoder.begin_group :string
if match[0] == ?L
encoder.text_token 'L', :modifier
match = '"'
end
encoder.text_token match, :delimiter
state = :string

elsif match = scan(/ [A-Za-z_][A-Za-z_0-9]* /x)
kind = IDENT_KIND[match]
if kind == :ident && label_expected && !in_preproc_line && scan(/:(?!:)/)
Expand All @@ -89,15 +98,6 @@ def scan_tokens encoder, options
end
encoder.text_token match, kind

elsif match = scan(/L?"/)
encoder.begin_group :string
if match[0] == ?L
encoder.text_token 'L', :modifier
match = '"'
end
encoder.text_token match, :delimiter
state = :string

elsif match = scan(/ \# \s* if \s* 0 /x)
match << scan_until(/ ^\# (?:elif|else|endif) .*? $ | \z /xm) unless eos?
encoder.text_token match, :comment
Expand Down
18 changes: 9 additions & 9 deletions lib/coderay/scanners/cpp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@ def scan_tokens encoder, options
end
encoder.text_token match, :operator

elsif match = scan(/L?"/)
encoder.begin_group :string
if match[0] == ?L
encoder.text_token 'L', :modifier
match = '"'
end
state = :string
encoder.text_token match, :delimiter

elsif match = scan(/ [A-Za-z_][A-Za-z_0-9]* /x)
kind = IDENT_KIND[match]
if kind == :ident && label_expected && !in_preproc_line && scan(/:(?!:)/)
Expand All @@ -110,15 +119,6 @@ def scan_tokens encoder, options
elsif match = scan(/\$/)
encoder.text_token match, :ident

elsif match = scan(/L?"/)
encoder.begin_group :string
if match[0] == ?L
encoder.text_token match, 'L', :modifier
match = '"'
end
state = :string
encoder.text_token match, :delimiter

elsif match = scan(/#[ \t]*(\w*)/)
encoder.text_token match, :preprocessor
in_preproc_line = true
Expand Down