3 pygments.lexers.graphics |
3 pygments.lexers.graphics |
4 ~~~~~~~~~~~~~~~~~~~~~~~~ |
4 ~~~~~~~~~~~~~~~~~~~~~~~~ |
5 |
5 |
6 Lexers for computer graphics and plotting related languages. |
6 Lexers for computer graphics and plotting related languages. |
7 |
7 |
8 :copyright: Copyright 2006-2020 by the Pygments team, see AUTHORS. |
8 :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS. |
9 :license: BSD, see LICENSE for details. |
9 :license: BSD, see LICENSE for details. |
10 """ |
10 """ |
11 |
11 |
12 from pygments.lexer import RegexLexer, words, include, bygroups, using, \ |
12 from pygments.lexer import RegexLexer, words, include, bygroups, using, \ |
13 this, default |
13 this, default |
423 (r'//(\n|(.|\n)*?[^\\]\n)', Comment), |
423 (r'//(\n|(.|\n)*?[^\\]\n)', Comment), |
424 (r'/(\\\n)?\*(.|\n)*?\*(\\\n)?/', Comment), |
424 (r'/(\\\n)?\*(.|\n)*?\*(\\\n)?/', Comment), |
425 ], |
425 ], |
426 'statements': [ |
426 'statements': [ |
427 # simple string (TeX friendly) |
427 # simple string (TeX friendly) |
428 (r'"(\\\\|\\"|[^"])*"', String), |
428 (r'"(\\\\|\\[^\\]|[^"\\])*"', String), |
429 # C style string (with character escapes) |
429 # C style string (with character escapes) |
430 (r"'", String, 'string'), |
430 (r"'", String, 'string'), |
431 (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[lL]?', Number.Float), |
431 (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[lL]?', Number.Float), |
432 (r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float), |
432 (r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float), |
433 (r'0x[0-9a-fA-F]+[Ll]?', Number.Hex), |
433 (r'0x[0-9a-fA-F]+[Ll]?', Number.Hex), |
773 (r'\b(x|y|z|u|v)\b', Name.Builtin.Pseudo), |
773 (r'\b(x|y|z|u|v)\b', Name.Builtin.Pseudo), |
774 (r'[a-zA-Z_]\w*', Name), |
774 (r'[a-zA-Z_]\w*', Name), |
775 (r'[0-9]+\.[0-9]*', Number.Float), |
775 (r'[0-9]+\.[0-9]*', Number.Float), |
776 (r'\.[0-9]+', Number.Float), |
776 (r'\.[0-9]+', Number.Float), |
777 (r'[0-9]+', Number.Integer), |
777 (r'[0-9]+', Number.Integer), |
778 (r'"(\\\\|\\"|[^"])*"', String), |
778 (r'"(\\\\|\\[^\\]|[^"\\])*"', String), |
779 (r'\s+', Text), |
779 (r'\s+', Text), |
780 ] |
780 ] |
781 } |
781 } |
|
782 |
|
783 def analyse_text(text): |
|
784 """POVRAY is similar to JSON/C, but the combination of camera and |
|
785 light_source is probably not very likely elsewhere. HLSL or GLSL |
|
786 are similar (GLSL even has #version), but they miss #declare, and |
|
787 light_source/camera are not keywords anywhere else -- it's fair |
|
788 to assume though that any POVRAY scene must have a camera and |
|
789 lightsource.""" |
|
790 result = 0 |
|
791 if '#version' in text: |
|
792 result += 0.05 |
|
793 if '#declare' in text: |
|
794 result += 0.05 |
|
795 if 'camera' in text: |
|
796 result += 0.05 |
|
797 if 'light_source' in text: |
|
798 result += 0.1 |
|
799 |
|
800 return result |