Skip to content
Merged
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
env:
global:
- "JRUBY_OPTS=-Xcext.enabled=true"
rvm:
- 1.8.7
- ree
Expand All @@ -7,9 +10,9 @@ rvm:
- 2.2
- 2.3.0
- ruby-head
- jruby-head
- jruby-18mode
- jruby-19mode
- jruby-head
- rbx-2
branches:
only:
Expand Down
3 changes: 1 addition & 2 deletions FOLDERS
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ Run them as functional tests with <code>rake test:demos</code>.

== etc - Lots of stuff

Some addidtional files for CodeRay, mainly graphics and Vim scripts.

Some additional files for CodeRay, mainly graphics and Vim scripts.

== lib - CodeRay library code

Expand Down
36 changes: 19 additions & 17 deletions lib/coderay/scanners/cpp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,45 @@ module CodeRay
module Scanners

# Scanner for C++.
#
#
# Aliases: +cplusplus+, c++
class CPlusPlus < Scanner

register_for :cpp
file_extension 'cpp'
title 'C++'

#-- http://www.cppreference.com/wiki/keywords/start
KEYWORDS = [
'and', 'and_eq', 'asm', 'bitand', 'bitor', 'break',
'case', 'catch', 'class', 'compl', 'const_cast',
'continue', 'default', 'delete', 'do', 'dynamic_cast', 'else',
'enum', 'export', 'for', 'goto', 'if', 'namespace', 'new',
'not', 'not_eq', 'or', 'or_eq', 'reinterpret_cast', 'return',
'sizeof', 'static_cast', 'struct', 'switch', 'template',
'throw', 'try', 'typedef', 'typeid', 'typename', 'union',
'sizeof', 'static_assert', 'static_cast', 'struct', 'switch',
'template', 'throw', 'try', 'typedef', 'typeid', 'typename', 'union',
'while', 'xor', 'xor_eq',
] # :nodoc:

PREDEFINED_TYPES = [
'bool', 'char', 'double', 'float', 'int', 'long',
'short', 'signed', 'unsigned', 'wchar_t', 'string',
'bool', 'char', 'char16_t', 'char32_t', 'double', 'float',
'int', 'long', 'short', 'signed', 'unsigned',
'wchar_t', 'string',
] # :nodoc:
PREDEFINED_CONSTANTS = [
'false', 'true',
'EOF', 'NULL',
'EOF', 'NULL', 'nullptr'
] # :nodoc:
PREDEFINED_VARIABLES = [
'this',
] # :nodoc:
DIRECTIVES = [
'auto', 'const', 'explicit', 'extern', 'friend', 'inline', 'mutable', 'operator',
'private', 'protected', 'public', 'register', 'static', 'using', 'virtual', 'void',
'volatile',
'alignas', 'alignof', 'auto', 'const', 'constexpr', 'decltype', 'explicit',
'extern', 'final', 'friend', 'inline', 'mutable', 'noexcept', 'operator',
'override', 'private', 'protected', 'public', 'register', 'static',
'thread_local', 'using', 'virtual', 'void', 'volatile',
] # :nodoc:

IDENT_KIND = WordList.new(:ident).
add(KEYWORDS, :keyword).
add(PREDEFINED_TYPES, :predefined_type).
Expand All @@ -48,9 +50,9 @@ class CPlusPlus < Scanner

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:

protected

def scan_tokens encoder, options

state = :initial
Expand Down Expand Up @@ -107,7 +109,7 @@ 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
Expand Down Expand Up @@ -180,7 +182,7 @@ def scan_tokens encoder, options
state = :initial

end

when :class_name_expected
if match = scan(/ [A-Za-z_][A-Za-z_0-9]* /x)
encoder.text_token match, :class
Expand All @@ -194,7 +196,7 @@ def scan_tokens encoder, options
state = :initial

end

else
raise_inspect 'Unknown state', encoder

Expand Down