Commits

Jeffrey Arnold  committed 632c29b

StanLexer: added CPP reserved keywords

  • Participants
  • Parent commits 24c1619

Comments (0)

Files changed (2)

File pygments/lexers/_stan_builtins.py

     'weibull',
     'wishart']
 
+CPP_RESERVED = [
+    'alignas',
+    'alignof',
+    'and',
+    'and_eq',
+    'asm',
+    'auto',
+    'bitand',
+    'bitor'
+    'bool',
+    'break',
+    'case',
+    'catch',
+    'char',
+    'char16_t',
+    'char32_t',
+    'class'
+    'compl',
+    'const',
+    'constexpr',
+    'const_cast',
+    'continue',
+    'decltype'
+    'default',
+    'delete',
+    'do',
+    'double',
+    'dynamic_cast',
+    'else',
+    'enum'
+    'explicit',
+    'export',
+    'extern',
+    'false',
+    'float',
+    'for',
+    'friend',
+    'goto'
+    'if',
+    'inline',
+    'int',
+    'long',
+    'mutable',
+    'namespace',
+    'new',
+    'noexcept'
+    'not',
+    'not_eq',
+    'nullptr',
+    'operator',
+    'or',
+    'or_eq',
+    'private',
+    'protected'
+    'public',
+    'register',
+    'reinterpret_cast',
+    'return',
+    'short',
+    'signed'
+    'sizeof',
+    'static',
+    'static_assert',
+    'static_cast',
+    'struct',
+    'switch'
+    'template',
+    'this',
+    'thread_local',
+    'throw',
+    'true',
+    'try',
+    'typedef'
+    'typeid',
+    'typename',
+    'union',
+    'unsigned',
+    'using',
+    'virtual',
+    'void'
+    'volatile',
+    'wchar_t',
+    'while',
+    'xor',
+    'xor_eq'
+    ]

File pygments/lexers/math.py

 # -*- coding: utf-8 -*-
 """
-    pygments.lexers.math
-    ~~~~~~~~~~~~~~~~~~~~
+pygments.lexers.math
+~~~~~~~~~~~~~~~~~~~~
 
-    Lexers for math languages.
+Lexers for math languages.
 
-    :copyright: Copyright 2006-2012 by the Pygments team, see AUTHORS.
-    :license: BSD, see LICENSE for details.
+:copyright: Copyright 2006-2012 by the Pygments team, see AUTHORS.
+:license: BSD, see LICENSE for details.
 """
 
 import re
 from pygments.lexer import Lexer, RegexLexer, bygroups, include, \
     combined, do_insertions
 from pygments.token import Comment, String, Punctuation, Keyword, Name, \
-    Operator, Number, Text, Generic
+    Operator, Number, Text, Generic, Error
 
 from pygments.lexers.agile import PythonLexer
 from pygments.lexers import _scilab_builtins
     filenames = ['*.stan']
 
     _RESERVED = ('for', 'in', 'while', 'repeat', 'until', 'if',
-                 'then', 'else', 'true', 'false', 'T', 
+                 'then', 'else', 'true', 'false', 'T',
                  'lower', 'upper', 'print')
 
     _TYPES = ('int', 'real', 'vector', 'simplex', 'ordered', 'row_vector',
              % r'|'.join(_stan_builtins.CONSTANTS), Keyword.Constant),
             # Special names ending in __, like lp__
             (r'[A-Za-z][A-Za-z0-9_]*__\b', Name.Builtin.Pseudo),
+            ('%s\b' % r'|'.join(_stan_builtins.CPP_RESERVED), Error),
             # Regular variable names
             (r'[A-Za-z][A-Za-z0-9_]*\b', Name),
             # Real Literals
             # Integer Literals
             (r'-?[0-9]+', Number.Integer),
             # Assignment operators
-            # SLexer makes these tokens Operators. 
+            # SLexer makes these tokens Operators.
             (r'<-|~', Operator),
             # Infix and prefix operators (and = )
             (r"\+|-|\.?\*|\.?/|\\|'|=", Operator),