3 pygments.lexers.usd |
3 pygments.lexers.usd |
4 ~~~~~~~~~~~~~~~~~~~ |
4 ~~~~~~~~~~~~~~~~~~~ |
5 |
5 |
6 The module that parses Pixar's Universal Scene Description file format. |
6 The module that parses Pixar's Universal Scene Description file format. |
7 |
7 |
8 :copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS. |
8 :copyright: Copyright 2006-2020 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, bygroups |
12 from pygments.lexer import RegexLexer, bygroups |
13 from pygments.lexer import words as words_ |
13 from pygments.lexer import words as words_ |
22 def _keywords(words, type_): |
22 def _keywords(words, type_): |
23 return [(words_(words, prefix=r"\b", suffix=r"\b"), type_)] |
23 return [(words_(words, prefix=r"\b", suffix=r"\b"), type_)] |
24 |
24 |
25 |
25 |
26 _TYPE = r"(\w+(?:\[\])?)" |
26 _TYPE = r"(\w+(?:\[\])?)" |
27 _BASE_ATTRIBUTE = r"([\w_]+(?:\:[\w_]+)*)(?:(\.)(timeSamples))?" |
27 _BASE_ATTRIBUTE = r"(\w+(?:\:\w+)*)(?:(\.)(timeSamples))?" |
28 _WHITESPACE = r"([ \t]+)" |
28 _WHITESPACE = r"([ \t]+)" |
29 |
29 |
30 |
30 |
31 class UsdLexer(RegexLexer): |
31 class UsdLexer(RegexLexer): |
32 """ |
32 """ |
67 [(r"\b\w+:[\w:]+\b", Name.Attribute)] + |
67 [(r"\b\w+:[\w:]+\b", Name.Attribute)] + |
68 _keywords(OPERATORS, Operator) + # more attributes |
68 _keywords(OPERATORS, Operator) + # more attributes |
69 [(type_ + r"\[\]", Keyword.Type) for type_ in TYPES] + |
69 [(type_ + r"\[\]", Keyword.Type) for type_ in TYPES] + |
70 _keywords(TYPES, Keyword.Type) + |
70 _keywords(TYPES, Keyword.Type) + |
71 [ |
71 [ |
72 (r"[\(\)\[\]{}]", Punctuation), |
72 (r"[(){}\[\]]", Punctuation), |
73 ("#.*?$", Comment.Single), |
73 ("#.*?$", Comment.Single), |
74 (",", Punctuation), |
74 (",", Punctuation), |
75 (";", Punctuation), # ";"s are allowed to combine separate metadata lines |
75 (";", Punctuation), # ";"s are allowed to combine separate metadata lines |
76 ("=", Operator), |
76 ("=", Operator), |
77 (r"[-]*([0-9]*[.])?[0-9]+(?:e[+-]*\d+)?", Number), |
77 (r"[-]*([0-9]*[.])?[0-9]+(?:e[+-]*\d+)?", Number), |
82 (r"<(\.\./)*([\w/]+|[\w/]+\.\w+[\w:]*)>", Name.Namespace), |
82 (r"<(\.\./)*([\w/]+|[\w/]+\.\w+[\w:]*)>", Name.Namespace), |
83 (r"@.*?@", String.Interpol), |
83 (r"@.*?@", String.Interpol), |
84 (r'\(.*"[.\\n]*".*\)', String.Doc), |
84 (r'\(.*"[.\\n]*".*\)', String.Doc), |
85 (r"\A#usda .+$", Comment.Hashbang), |
85 (r"\A#usda .+$", Comment.Hashbang), |
86 (r"\s+", Whitespace), |
86 (r"\s+", Whitespace), |
87 (r"[\w_]+", Text), |
87 (r"\w+", Text), |
88 (r"[_:\.]+", Punctuation), |
88 (r"[_:.]+", Punctuation), |
89 ], |
89 ], |
90 } |
90 } |