Anonymous avatar Anonymous committed cad08ab

POV-Ray lexer provided by pi31 on the irc channel. Clsoes #348.

Comments (0)

Files changed (4)

pygments/lexers/_mapping.py

     'OcamlLexer': ('pygments.lexers.functional', 'OCaml', ('ocaml',), ('*.ml', '*.mli', '*.mll', '*.mly'), ('text/x-ocaml',)),
     'PerlLexer': ('pygments.lexers.agile', 'Perl', ('perl', 'pl'), ('*.pl', '*.pm'), ('text/x-perl', 'application/x-perl')),
     'PhpLexer': ('pygments.lexers.web', 'PHP', ('php', 'php3', 'php4', 'php5'), ('*.php', '*.php[345]'), ('text/x-php',)),
+    'PovrayLexer': ('pygments.lexers.other', 'POVRay', ('pov',), ('*.pov', '*.inc'), ('text/x-povray',)),
     'Python3Lexer': ('pygments.lexers.agile', 'Python 3', ('python3', 'py3'), (), ('text/x-python3', 'application/x-python3')),
     'PythonConsoleLexer': ('pygments.lexers.agile', 'Python console session', ('pycon',), (), ('text/x-python-doctest',)),
     'PythonLexer': ('pygments.lexers.agile', 'Python', ('python', 'py'), ('*.py', '*.pyw', '*.sc', 'SConstruct', 'SConscript'), ('text/x-python', 'application/x-python')),

pygments/lexers/other.py

 
 __all__ = ['SqlLexer', 'MySqlLexer', 'BrainfuckLexer', 'BashLexer',
            'BatchLexer', 'BefungeLexer', 'RedcodeLexer', 'MOOCodeLexer',
-           'SmalltalkLexer', 'TcshLexer', 'LogtalkLexer', 'GnuplotLexer']
+           'SmalltalkLexer', 'TcshLexer', 'LogtalkLexer', 'GnuplotLexer',
+           'PovrayLexer']
 
 
 class SqlLexer(RegexLexer):
             include('genericargs'),
         ],
     }
+
+
+class PovrayLexer(RegexLexer):
+    """
+    For `Persistence of Vision Raytracer http://www.povray.org/>`_ files.
+
+    *New in Pygments 0.11.*
+    """
+    name = 'POVRay'
+    aliases = ['pov']
+    filenames = ['*.pov', '*.inc']
+    mimetypes = ['text/x-povray']
+
+    tokens = {
+        'root': [
+            (r'/\*[\w\W]*?\*/', Comment.Multiline),
+            (r'//.*\n', Comment.Single),
+            (r'"(?:\\.|[^"])+"', String.Double),
+            (r'#(debug|default|else|end|error|fclose|fopen|if|ifdef|ifndef|'
+             r'include|range|read|render|statistics|switch|undef|version|'
+             r'warning|while|write|define|macro|local|declare)',
+             Comment.Preproc),
+            (r'\b(aa_level|aa_threshold|abs|acos|acosh|adaptive|adc_bailout|'
+             r'agate|agate_turb|all|alpha|ambient|ambient_light|angle|'
+             r'aperture|arc_angle|area_light|asc|asin|asinh|assumed_gamma|'
+             r'atan|atan2|atanh|atmosphere|atmospheric_attenuation|'
+             r'attenuating|average|background|black_hole|blue|blur_samples|'
+             r'bounded_by|box_mapping|bozo|break|brick|brick_size|'
+             r'brightness|brilliance|bumps|bumpy1|bumpy2|bumpy3|bump_map|'
+             r'bump_size|case|caustics|ceil|checker|chr|clipped_by|clock|'
+             r'color|color_map|colour|colour_map|component|composite|concat|'
+             r'confidence|conic_sweep|constant|control0|control1|cos|cosh|'
+             r'count|crackle|crand|cube|cubic_spline|cylindrical_mapping|'
+             r'debug|declare|default|degrees|dents|diffuse|direction|'
+             r'distance|distance_maximum|div|dust|dust_type|eccentricity|'
+             r'else|emitting|end|error|error_bound|exp|exponent|'
+             r'fade_distance|fade_power|falloff|falloff_angle|false|'
+             r'file_exists|filter|finish|fisheye|flatness|flip|floor|'
+             r'focal_point|fog|fog_alt|fog_offset|fog_type|frequency|gif|'
+             r'global_settings|glowing|gradient|granite|gray_threshold|'
+             r'green|halo|hexagon|hf_gray_16|hierarchy|hollow|hypercomplex|'
+             r'if|ifdef|iff|image_map|incidence|include|int|interpolate|'
+             r'inverse|ior|irid|irid_wavelength|jitter|lambda|leopard|'
+             r'linear|linear_spline|linear_sweep|location|log|looks_like|'
+             r'look_at|low_error_factor|mandel|map_type|marble|material_map|'
+             r'matrix|max|max_intersections|max_iteration|max_trace_level|'
+             r'max_value|metallic|min|minimum_reuse|mod|mortar|'
+             r'nearest_count|no|normal|normal_map|no_shadow|number_of_waves|'
+             r'octaves|off|offset|omega|omnimax|on|once|onion|open|'
+             r'orthographic|panoramic|pattern1|pattern2|pattern3|'
+             r'perspective|pgm|phase|phong|phong_size|pi|pigment|'
+             r'pigment_map|planar_mapping|png|point_at|pot|pow|ppm|'
+             r'precision|pwr|quadratic_spline|quaternion|quick_color|'
+             r'quick_colour|quilted|radial|radians|radiosity|radius|rainbow|'
+             r'ramp_wave|rand|range|reciprocal|recursion_limit|red|'
+             r'reflection|refraction|render|repeat|rgb|rgbf|rgbft|rgbt|'
+             r'right|ripples|rotate|roughness|samples|scale|scallop_wave|'
+             r'scattering|seed|shadowless|sin|sine_wave|sinh|sky|sky_sphere|'
+             r'slice|slope_map|smooth|specular|spherical_mapping|spiral|'
+             r'spiral1|spiral2|spotlight|spotted|sqr|sqrt|statistics|str|'
+             r'strcmp|strength|strlen|strlwr|strupr|sturm|substr|switch|sys|'
+             r't|tan|tanh|test_camera_1|test_camera_2|test_camera_3|'
+             r'test_camera_4|texture|texture_map|tga|thickness|threshold|'
+             r'tightness|tile2|tiles|track|transform|translate|transmit|'
+             r'triangle_wave|true|ttf|turbulence|turb_depth|type|'
+             r'ultra_wide_angle|up|use_color|use_colour|use_index|u_steps|'
+             r'val|variance|vaxis_rotate|vcross|vdot|version|vlength|'
+             r'vnormalize|volume_object|volume_rendered|vol_with_light|'
+             r'vrotate|v_steps|warning|warp|water_level|waves|while|width|'
+             r'wood|wrinkles|yes)\b', Keyword),
+            (r'bicubic_patch|blob|box|camera|cone|cubic|cylinder|difference|'
+             r'disc|height_field|intersection|julia_fractal|lathe|'
+             r'light_source|merge|mesh|object|plane|poly|polygon|prism|'
+             r'quadric|quartic|smooth_triangle|sor|sphere|superellipsoid|'
+             r'text|torus|triangle|union', Name.Builtin),
+            #TODO: <=, etc
+            (r'[\[\](){}<>;,]', Punctuation),
+            (r'[-+*/=]', Operator),
+            (r'\b(x|y|z|u|v)\b', Name.Builtin.Pseudo),
+            (r'[a-zA-Z_][a-zA-Z_0-9]*', Name),
+            (r'[0-9]+\.[0-9]*', Number.Float),
+            (r'\.[0-9]+', Number.Float),
+            (r'[0-9]+', Number.Integer),
+            (r'\s+', Text),
+        ]
+    }

tests/examplefiles/sphere.pov

+#include "colors.inc"    
+
+background { color Cyan }
+
+camera {
+  location <0, 2, -3>
+  look_at <0, 1, 2>
+}
+
+sphere {
+  <0, 1, 2>, 2
+  texture {
+    pigment { color Yellow }
+  }
+}
+
+light_source { <2, 4, -3> color White}
+

tests/examplefiles/while.pov

+#declare Index1 = 0;
+#while(Index1 <= 9)
+
+   #declare Index2 = 0;
+   #while(Index2 <= 19)
+
+      sphere { <Index1, Index2, 0>, .5 }
+
+      #declare Index2 = Index2 + 1;
+   #end
+
+   #declare Index1 = Index1 + 1;
+#end
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.