summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FOLDERS96
-rw-r--r--lib/coderay/scanners/cpp.rb38
2 files changed, 68 insertions, 66 deletions
diff --git a/FOLDERS b/FOLDERS
index f29255a..1709d08 100644
--- a/FOLDERS
+++ b/FOLDERS
@@ -1,48 +1,48 @@
-= CodeRay - folder structure
-
-== bench - Benchmarking system
-
-All benchmarking stuff goes here.
-
-Test inputs are stored in files named <code>example.<lang></code>.
-Test outputs go to <code>bench/test.<encoder-default-file-extension></code>.
-
-Run <code>bench/bench.rb</code> to get a usage description.
-
-Run <code>rake bench</code> to perform an example benchmark.
-
-
-== bin - Scripts
-
-Executional files for CodeRay.
-
-coderay:: The CodeRay executable.
-
-== demo - Demos and functional tests
-
-Demonstrational scripts to show of CodeRay's features.
-
-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.
-
-
-== lib - CodeRay library code
-
-This is the base directory for the CodeRay library.
-
-
-== rake_helpers - Rake helper libraries
-
-Some files to enhance Rake, including the Autumnal Rdoc template and some scripts.
-
-
-== test - Tests
-
-In the subfolder scanners/ are the scanners tests.
-Each language has its own subfolder and sub-suite.
-
-Run with <code>rake test</code>.
+= CodeRay - folder structure
+
+== bench - Benchmarking system
+
+All benchmarking stuff goes here.
+
+Test inputs are stored in files named <code>example.<lang></code>.
+Test outputs go to <code>bench/test.<encoder-default-file-extension></code>.
+
+Run <code>bench/bench.rb</code> to get a usage description.
+
+Run <code>rake bench</code> to perform an example benchmark.
+
+
+== bin - Scripts
+
+Executional files for CodeRay.
+
+coderay:: The CodeRay executable.
+
+== demo - Demos and functional tests
+
+Demonstrational scripts to show of CodeRay's features.
+
+Run them as functional tests with <code>rake test:demos</code>.
+
+
+== etc - Lots of stuff
+
+Some additional files for CodeRay, mainly graphics and Vim scripts.
+
+
+== lib - CodeRay library code
+
+This is the base directory for the CodeRay library.
+
+
+== rake_helpers - Rake helper libraries
+
+Some files to enhance Rake, including the Autumnal Rdoc template and some scripts.
+
+
+== test - Tests
+
+In the subfolder scanners/ are the scanners tests.
+Each language has its own subfolder and sub-suite.
+
+Run with <code>rake test</code>.
diff --git a/lib/coderay/scanners/cpp.rb b/lib/coderay/scanners/cpp.rb
index e61f56f..50a25b7 100644
--- a/lib/coderay/scanners/cpp.rb
+++ b/lib/coderay/scanners/cpp.rb
@@ -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',
+ 'enum', 'export', 'final', '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', '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).
@@ -48,9 +50,9 @@ module Scanners
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
@@ -107,7 +109,7 @@ module Scanners
elsif match = scan(/\$/)
encoder.text_token match, :ident
-
+
elsif match = scan(/L?"/)
encoder.begin_group :string
if match[0] == ?L
@@ -180,7 +182,7 @@ module Scanners
state = :initial
end
-
+
when :class_name_expected
if match = scan(/ [A-Za-z_][A-Za-z_0-9]* /x)
encoder.text_token match, :class
@@ -194,7 +196,7 @@ module Scanners
state = :initial
end
-
+
else
raise_inspect 'Unknown state', encoder