MCPcopy Create free account
hub / github.com/python/cpython / ASDLLexer

Class ASDLLexer

Doc/tools/extensions/lexers/asdl_lexer.py:5–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3
4
5class ASDLLexer(RegexLexer):
6 name = "ASDL"
7 aliases = ["asdl"]
8 filenames = ["*.asdl"]
9 _name = r"([^\W\d]\w*)"
10 _text_ws = r"(\s*)"
11
12 tokens = {
13 "ws": [
14 (r"\n", Text),
15 (r"\s+", Text),
16 (r"--.*?$", Comment.Singleline),
17 ],
18 "root": [
19 include("ws"),
20 (
21 r"(module)" + _text_ws + _name,
22 bygroups(Keyword, Text, Name.Tag),
23 ),
24 (
25 r"(\w+)([\?\*]*\s)(\w+)",
26 bygroups(Name.Builtin.Pseudo, Operator, Name),
27 ),
28 # Keep in line with ``builtin_types`` from Parser/asdl.py.
29 # ASDL's 4 builtin types are
30 # constant, identifier, int, string
31 ("constant|identifier|int|string", Name.Builtin),
32 (r"attributes", Name.Builtin),
33 (
34 _name + _text_ws + "(=)",
35 bygroups(Name, Text, Operator),
36 ),
37 (_name, Name.Class),
38 (r"\|", Operator),
39 (r"{|}|\(|\)", Punctuation),
40 (r".", Text),
41 ],
42 }

Callers

nothing calls this directly

Calls 1

includeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…