summaryrefslogtreecommitdiff
path: root/pygments/lexers/graphics.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2014-09-16 18:58:00 +0200
committerGeorg Brandl <georg@python.org>2014-09-16 18:58:00 +0200
commitca80bbb894f18e7ccbda553d33b50ed222e7727f (patch)
tree25b7ab988b71e48ca6e90c41cc25e962b4014fb1 /pygments/lexers/graphics.py
parent98dac60db6d954fae554b9b77eec2197f533fdaf (diff)
downloadpygments-ca80bbb894f18e7ccbda553d33b50ed222e7727f.tar.gz
split up lexers.compiled into multiple submodules
Diffstat (limited to 'pygments/lexers/graphics.py')
-rw-r--r--pygments/lexers/graphics.py73
1 files changed, 73 insertions, 0 deletions
diff --git a/pygments/lexers/graphics.py b/pygments/lexers/graphics.py
new file mode 100644
index 00000000..de7db6ba
--- /dev/null
+++ b/pygments/lexers/graphics.py
@@ -0,0 +1,73 @@
+# -*- coding: utf-8 -*-
+"""
+ pygments.lexers.graphics
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+
+ Lexers for computer graphics related languages.
+
+ :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS.
+ :license: BSD, see LICENSE for details.
+"""
+
+from pygments.lexer import RegexLexer, words
+from pygments.token import Text, Comment, Operator, Keyword, Name, \
+ Number, Punctuation
+
+__all__ = ['GLShaderLexer']
+
+
+class GLShaderLexer(RegexLexer):
+ """
+ GLSL (OpenGL Shader) lexer.
+
+ .. versionadded:: 1.1
+ """
+ name = 'GLSL'
+ aliases = ['glsl']
+ filenames = ['*.vert', '*.frag', '*.geo']
+ mimetypes = ['text/x-glslsrc']
+
+ tokens = {
+ 'root': [
+ (r'^#.*', Comment.Preproc),
+ (r'//.*', Comment.Single),
+ (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
+ (r'\+|-|~|!=?|\*|/|%|<<|>>|<=?|>=?|==?|&&?|\^|\|\|?',
+ Operator),
+ (r'[?:]', Operator), # quick hack for ternary
+ (r'\bdefined\b', Operator),
+ (r'[;{}(),\[\]]', Punctuation),
+ # FIXME when e is present, no decimal point needed
+ (r'[+-]?\d*\.\d+([eE][-+]?\d+)?', Number.Float),
+ (r'[+-]?\d+\.\d*([eE][-+]?\d+)?', Number.Float),
+ (r'0[xX][0-9a-fA-F]*', Number.Hex),
+ (r'0[0-7]*', Number.Oct),
+ (r'[1-9][0-9]*', Number.Integer),
+ (words((
+ 'attribute', 'const', 'uniform', 'varying', 'centroid', 'break',
+ 'continue', 'do', 'for', 'while', 'if', 'else', 'in', 'out',
+ 'inout', 'float', 'int', 'void', 'bool', 'true', 'false',
+ 'invariant', 'discard', 'return', 'mat2', 'mat3' 'mat4',
+ 'mat2x2', 'mat3x2', 'mat4x2', 'mat2x3', 'mat3x3', 'mat4x3',
+ 'mat2x4', 'mat3x4', 'mat4x4', 'vec2', 'vec3', 'vec4',
+ 'ivec2', 'ivec3', 'ivec4', 'bvec2', 'bvec3', 'bvec4',
+ 'sampler1D', 'sampler2D', 'sampler3D' 'samplerCube',
+ 'sampler1DShadow', 'sampler2DShadow', 'struct'),
+ prefix=r'\b', suffix=r'\b'),
+ Keyword),
+ (words((
+ 'asm', 'class', 'union', 'enum', 'typedef', 'template', 'this',
+ 'packed', 'goto', 'switch', 'default', 'inline', 'noinline',
+ 'volatile', 'public', 'static', 'extern', 'external', 'interface',
+ 'long', 'short', 'double', 'half', 'fixed', 'unsigned', 'lowp',
+ 'mediump', 'highp', 'precision', 'input', 'output',
+ 'hvec2', 'hvec3', 'hvec4', 'dvec2', 'dvec3', 'dvec4',
+ 'fvec2', 'fvec3', 'fvec4', 'sampler2DRect', 'sampler3DRect',
+ 'sampler2DRectShadow', 'sizeof', 'cast', 'namespace', 'using'),
+ prefix=r'\b', suffix=r'\b'),
+ Keyword), # future use
+ (r'[a-zA-Z_][a-zA-Z_0-9]*', Name),
+ (r'\.', Punctuation),
+ (r'\s+', Text),
+ ],
+ }