code-explore-by-sql 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- code_explore_by_sql-0.1.0.dist-info/METADATA +205 -0
- code_explore_by_sql-0.1.0.dist-info/RECORD +29 -0
- code_explore_by_sql-0.1.0.dist-info/WHEEL +4 -0
- code_explore_by_sql-0.1.0.dist-info/entry_points.txt +3 -0
- code_explore_by_sql-0.1.0.dist-info/licenses/LICENSE +21 -0
- code_source_sql/__init__.py +9 -0
- code_source_sql/__main__.py +5 -0
- code_source_sql/bracket_scanner.py +385 -0
- code_source_sql/build_db.py +284 -0
- code_source_sql/code_block_summary.py +522 -0
- code_source_sql/configs.py +402 -0
- code_source_sql/db.py +625 -0
- code_source_sql/edge_extractor.py +183 -0
- code_source_sql/languages/__init__.py +31 -0
- code_source_sql/languages/c.py +118 -0
- code_source_sql/languages/cpp.py +106 -0
- code_source_sql/languages/csharp.py +103 -0
- code_source_sql/languages/glsl.py +162 -0
- code_source_sql/languages/go.py +91 -0
- code_source_sql/languages/hlsl.py +155 -0
- code_source_sql/languages/java.py +98 -0
- code_source_sql/languages/javascript.py +215 -0
- code_source_sql/languages/kotlin.py +108 -0
- code_source_sql/languages/python.py +105 -0
- code_source_sql/languages/rust.py +91 -0
- code_source_sql/languages/swift.py +116 -0
- code_source_sql/server.py +264 -0
- code_source_sql/symbol_analyzer.py +487 -0
- code_source_sql/unreal_rules.py +163 -0
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"""GLSL (OpenGL Shading Language) configuration.
|
|
2
|
+
|
|
3
|
+
Supports struct, uniform blocks, buffer blocks (SSBO), layout() qualifiers,
|
|
4
|
+
and standard C-like function syntax. No classes, namespaces, templates, or
|
|
5
|
+
semantic annotations.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import re
|
|
11
|
+
|
|
12
|
+
from ..configs import LanguageConfig
|
|
13
|
+
|
|
14
|
+
_NEVER_MATCH = re.compile(r"(?!x)x")
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def make_glsl_language() -> LanguageConfig:
|
|
18
|
+
"""GLSL language configuration — C-like shader language for OpenGL/Vulkan."""
|
|
19
|
+
return LanguageConfig(
|
|
20
|
+
name="glsl",
|
|
21
|
+
# Only struct — no class or interface in GLSL
|
|
22
|
+
class_re=re.compile(
|
|
23
|
+
r"(?:^|\s)(struct)\s+"
|
|
24
|
+
r"(\w+)"
|
|
25
|
+
r"\s*",
|
|
26
|
+
),
|
|
27
|
+
# No enums in GLSL
|
|
28
|
+
enum_re=_NEVER_MATCH,
|
|
29
|
+
# No namespaces in GLSL
|
|
30
|
+
namespace_re=_NEVER_MATCH,
|
|
31
|
+
func_name_re=re.compile(r"(\w+)\s*\([^)]*\)\s*$"),
|
|
32
|
+
# No export macros
|
|
33
|
+
export_macro_re=_NEVER_MATCH,
|
|
34
|
+
# No calling conventions
|
|
35
|
+
calling_conv_re=_NEVER_MATCH,
|
|
36
|
+
# Strip layout(...) qualifiers before classification
|
|
37
|
+
attribute_re=re.compile(
|
|
38
|
+
r"\blayout\s*\([^)]*\)\s*"
|
|
39
|
+
),
|
|
40
|
+
# No templates
|
|
41
|
+
template_re=_NEVER_MATCH,
|
|
42
|
+
# No destructors
|
|
43
|
+
dtor_re=_NEVER_MATCH,
|
|
44
|
+
control_flow_re=re.compile(r"\b(if|else\s+if|else|while|for|do|switch)\b"),
|
|
45
|
+
control_flow_names=frozenset({
|
|
46
|
+
"if", "else", "while", "for", "do", "switch",
|
|
47
|
+
"return", "break", "continue", "discard",
|
|
48
|
+
}),
|
|
49
|
+
# Includes precision qualifiers
|
|
50
|
+
trailing_mods_re=re.compile(
|
|
51
|
+
r"\s*(?:const|highp|mediump|lowp)\s*[;{]*\s*$"
|
|
52
|
+
),
|
|
53
|
+
# No access specifiers
|
|
54
|
+
access_spec_re=_NEVER_MATCH,
|
|
55
|
+
macro_like_re=re.compile(r"^[A-Z][A-Z0-9_]*\s*(?:\([^{};]*\))?\s*$"),
|
|
56
|
+
define_re=re.compile(r"#\s*define\s+"),
|
|
57
|
+
# No extern "C"
|
|
58
|
+
extern_c_re=_NEVER_MATCH,
|
|
59
|
+
# No operator overloading
|
|
60
|
+
operator_re=None,
|
|
61
|
+
uses_braces=True,
|
|
62
|
+
uses_namespaces=False,
|
|
63
|
+
uses_colon_inheritance=False,
|
|
64
|
+
# Edge extraction
|
|
65
|
+
scope_operator="::",
|
|
66
|
+
base_keyword="",
|
|
67
|
+
static_call_re=None,
|
|
68
|
+
super_call_re=None,
|
|
69
|
+
# PascalCase user-defined struct types
|
|
70
|
+
type_re=re.compile(r"\b([A-Z][A-Za-z0-9_]+)\b"),
|
|
71
|
+
param_type_re=re.compile(
|
|
72
|
+
r"(?:const\s+)?([A-Z][A-Za-z0-9_]+)\s+\w+"
|
|
73
|
+
),
|
|
74
|
+
basic_skip_types=frozenset({
|
|
75
|
+
# Scalar types
|
|
76
|
+
"float", "double", "int", "uint", "bool", "void",
|
|
77
|
+
# Vector types
|
|
78
|
+
"vec2", "vec3", "vec4",
|
|
79
|
+
"ivec2", "ivec3", "ivec4",
|
|
80
|
+
"uvec2", "uvec3", "uvec4",
|
|
81
|
+
"bvec2", "bvec3", "bvec4",
|
|
82
|
+
"dvec2", "dvec3", "dvec4",
|
|
83
|
+
# Matrix types
|
|
84
|
+
"mat2", "mat3", "mat4",
|
|
85
|
+
"mat2x2", "mat2x3", "mat2x4",
|
|
86
|
+
"mat3x2", "mat3x3", "mat3x4",
|
|
87
|
+
"mat4x2", "mat4x3", "mat4x4",
|
|
88
|
+
"dmat2", "dmat3", "dmat4",
|
|
89
|
+
# Sampler types
|
|
90
|
+
"sampler2D", "sampler3D", "samplerCube",
|
|
91
|
+
"sampler2DShadow", "samplerCubeShadow",
|
|
92
|
+
"sampler2DArray", "sampler2DArrayShadow",
|
|
93
|
+
"sampler1D", "sampler1DShadow",
|
|
94
|
+
"samplerBuffer", "sampler2DRect",
|
|
95
|
+
"sampler2DMS", "sampler2DMSArray",
|
|
96
|
+
"isampler2D", "isampler3D", "isamplerCube",
|
|
97
|
+
"usampler2D", "usampler3D", "usamplerCube",
|
|
98
|
+
# Image types
|
|
99
|
+
"image2D", "image3D", "imageCube", "imageBuffer",
|
|
100
|
+
"iimage2D", "uimage2D",
|
|
101
|
+
# Atomic types
|
|
102
|
+
"atomic_uint",
|
|
103
|
+
# Storage/precision qualifiers (noise when used as type-like tokens)
|
|
104
|
+
"in", "out", "inout", "uniform", "const",
|
|
105
|
+
"attribute", "varying",
|
|
106
|
+
"highp", "mediump", "lowp",
|
|
107
|
+
"readonly", "writeonly", "coherent",
|
|
108
|
+
}),
|
|
109
|
+
# Block classification helpers
|
|
110
|
+
block_keyword_re=re.compile(
|
|
111
|
+
r"\b(?:struct|uniform|buffer)\b"
|
|
112
|
+
),
|
|
113
|
+
# No lambdas
|
|
114
|
+
lambda_re=None,
|
|
115
|
+
# uniform/buffer blocks recognized as namespace-like blocks
|
|
116
|
+
# attribute_re already stripped layout(...), leaving clean "uniform Name"
|
|
117
|
+
namespace_sig_re=re.compile(
|
|
118
|
+
r"(?:uniform|buffer)\s+(\w+)\s*$"
|
|
119
|
+
),
|
|
120
|
+
init_list_re=None,
|
|
121
|
+
# View / summary helpers
|
|
122
|
+
access_spec_names=frozenset(),
|
|
123
|
+
view_structural_kws=("struct ", "uniform ", "buffer "),
|
|
124
|
+
view_modifier_kws=("const ", "static "),
|
|
125
|
+
local_var_modifiers="const|uniform|volatile|highp|mediump|lowp|readonly|writeonly|coherent",
|
|
126
|
+
# Bracket scanner hints
|
|
127
|
+
verbatim_string_prefix=None,
|
|
128
|
+
raw_string_char=None,
|
|
129
|
+
# No range-based for in GLSL
|
|
130
|
+
range_for_re=None,
|
|
131
|
+
# Comment syntax (same as C)
|
|
132
|
+
line_comment="//",
|
|
133
|
+
block_comment_pair=("/*", "*/"),
|
|
134
|
+
# String syntax — only double-quoted strings in GLSL
|
|
135
|
+
string_delimiters=frozenset({'"'}),
|
|
136
|
+
string_escape_char="\\",
|
|
137
|
+
triple_quote_strings=(),
|
|
138
|
+
# Block style
|
|
139
|
+
uses_indent_blocks=False,
|
|
140
|
+
# Preprocessor
|
|
141
|
+
preprocessor_prefix="#",
|
|
142
|
+
has_preprocessor_macros=True,
|
|
143
|
+
# Statement / block close
|
|
144
|
+
statement_terminator=";",
|
|
145
|
+
block_close_suffix="};",
|
|
146
|
+
summary_comment_prefix="//",
|
|
147
|
+
# Config-driven control flow
|
|
148
|
+
control_flow_patterns=(
|
|
149
|
+
("for", re.compile(r"^\s*for\s*\((.{1,80})\)\s*\{?\s*$")),
|
|
150
|
+
("while", re.compile(r"^\s*while\s*\((.{1,80})\)\s*\{?\s*$")),
|
|
151
|
+
("if", re.compile(r"^\s*(?:else\s+)?if\s*\((.{1,80})\)\s*\{?\s*$")),
|
|
152
|
+
("switch", re.compile(r"^\s*switch\s*\((.{1,40})\)\s*\{?\s*$")),
|
|
153
|
+
),
|
|
154
|
+
return_re=re.compile(r"^\s*return\s+(.{1,60});"),
|
|
155
|
+
# Extra syntax hints
|
|
156
|
+
type_indicator_chars="",
|
|
157
|
+
define_line_re=re.compile(r"#\s*define\s+(\w+)(\([^)]*\))?\s*(.*)"),
|
|
158
|
+
has_template_strings=False,
|
|
159
|
+
raw_string_style="cpp",
|
|
160
|
+
# No semantic annotations in GLSL — standard C function signature end
|
|
161
|
+
func_sig_end_re=re.compile(r"\)\s*$"),
|
|
162
|
+
)
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"""Go language configuration."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import re
|
|
6
|
+
|
|
7
|
+
from ..configs import LanguageConfig
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def make_go_language() -> LanguageConfig:
|
|
11
|
+
"""Go language configuration."""
|
|
12
|
+
return LanguageConfig(
|
|
13
|
+
name="go",
|
|
14
|
+
class_re=re.compile(r"\b(type)\s+(\w+)\s+(?:struct|interface)\b(?:\s*(?://.*)?$)?"),
|
|
15
|
+
enum_re=re.compile(r"(?!x)x"), # never-match; Go has no enum keyword
|
|
16
|
+
namespace_re=re.compile(r"(?!x)x"), # never-match; Go uses package, not namespace blocks
|
|
17
|
+
func_name_re=re.compile(r"func\s+(?:\(\w+\s+\*?\w+\)\s+)?(\w+)\s*\("),
|
|
18
|
+
export_macro_re=re.compile(r"(?!x)x"),
|
|
19
|
+
calling_conv_re=re.compile(r"(?!x)x"),
|
|
20
|
+
attribute_re=re.compile(r"(?!x)x"),
|
|
21
|
+
template_re=re.compile(r"\[[^\]]+\]"), # Go generics: [T any]
|
|
22
|
+
dtor_re=re.compile(r"(?!x)x"),
|
|
23
|
+
control_flow_re=re.compile(r"\b(if|else|for|range|switch|case|select|go|defer|return)\b"),
|
|
24
|
+
control_flow_names=frozenset({
|
|
25
|
+
"if", "else", "for", "switch", "case", "select", "go", "defer",
|
|
26
|
+
"return", "break", "continue", "fallthrough", "goto", "range",
|
|
27
|
+
}),
|
|
28
|
+
trailing_mods_re=re.compile(r"(?!x)x"),
|
|
29
|
+
access_spec_re=re.compile(r"(?!x)x"),
|
|
30
|
+
macro_like_re=re.compile(r"(?!x)x"),
|
|
31
|
+
define_re=re.compile(r"(?!x)x"),
|
|
32
|
+
extern_c_re=re.compile(r"(?!x)x"),
|
|
33
|
+
operator_re=None,
|
|
34
|
+
uses_braces=True,
|
|
35
|
+
uses_namespaces=False,
|
|
36
|
+
uses_colon_inheritance=False,
|
|
37
|
+
scope_operator=".",
|
|
38
|
+
base_keyword="", # Go has no super/base; embedded fields accessed directly
|
|
39
|
+
static_call_re=re.compile(r"\b([A-Z][A-Za-z0-9_]*)\.([A-Za-z_][A-Za-z0-9_]*)\s*\("),
|
|
40
|
+
super_call_re=None,
|
|
41
|
+
type_re=re.compile(r"\b([A-Z][A-Za-z0-9_]*)\b"), # exported names are PascalCase
|
|
42
|
+
param_type_re=re.compile(r"([A-Z][A-Za-z0-9_]*(?:<[^>]*>)?)\s+"),
|
|
43
|
+
basic_skip_types=frozenset({
|
|
44
|
+
"int", "int8", "int16", "int32", "int64",
|
|
45
|
+
"uint", "uint8", "uint16", "uint32", "uint64",
|
|
46
|
+
"float32", "float64", "string", "bool", "byte", "rune",
|
|
47
|
+
"error", "complex64", "complex128", "uintptr",
|
|
48
|
+
}),
|
|
49
|
+
block_keyword_re=re.compile(r"\b(?:func|type|struct|interface|map|chan)\b"),
|
|
50
|
+
lambda_re=re.compile(r"func\s*\("), # Go anonymous functions
|
|
51
|
+
namespace_sig_re=None,
|
|
52
|
+
init_list_re=None,
|
|
53
|
+
access_spec_names=frozenset(),
|
|
54
|
+
view_structural_kws=("type ", "func "),
|
|
55
|
+
view_modifier_kws=("go ", "defer "),
|
|
56
|
+
local_var_modifiers="var|const",
|
|
57
|
+
verbatim_string_prefix=None,
|
|
58
|
+
raw_string_char=None, # Go uses backtick for raw strings
|
|
59
|
+
range_for_re=re.compile(
|
|
60
|
+
r"for\s+(?:\w+(?:,\s*\w+)?\s*:=\s+)?range\s+(\w+)"
|
|
61
|
+
),
|
|
62
|
+
# Comment syntax
|
|
63
|
+
line_comment="//",
|
|
64
|
+
block_comment_pair=("/*", "*/"),
|
|
65
|
+
# String syntax
|
|
66
|
+
string_delimiters=frozenset({'"'}),
|
|
67
|
+
string_escape_char="\\",
|
|
68
|
+
triple_quote_strings=(),
|
|
69
|
+
# Block style
|
|
70
|
+
uses_indent_blocks=False,
|
|
71
|
+
# Preprocessor
|
|
72
|
+
preprocessor_prefix="",
|
|
73
|
+
has_preprocessor_macros=False,
|
|
74
|
+
# Statement / block close
|
|
75
|
+
statement_terminator="", # Go has no semicolons
|
|
76
|
+
block_close_suffix="}",
|
|
77
|
+
summary_comment_prefix="//",
|
|
78
|
+
# Config-driven control flow
|
|
79
|
+
control_flow_patterns=(
|
|
80
|
+
("for", re.compile(r"^\s*for\s+(.{1,80})\s*\{?\s*$")),
|
|
81
|
+
("if", re.compile(r"^\s*if\s+(.{1,80})\s*\{?\s*$")),
|
|
82
|
+
("switch", re.compile(r"^\s*switch\s+(.{1,40})\s*\{?\s*$")),
|
|
83
|
+
("select", re.compile(r"^\s*select\s*\{?\s*$")),
|
|
84
|
+
),
|
|
85
|
+
return_re=re.compile(r"^\s*return\s+(.{1,60})"), # no semicolons in Go
|
|
86
|
+
# Extra syntax hints
|
|
87
|
+
type_indicator_chars="",
|
|
88
|
+
define_line_re=None,
|
|
89
|
+
has_template_strings=False,
|
|
90
|
+
raw_string_style="cpp",
|
|
91
|
+
)
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"""HLSL (High-Level Shading Language) configuration.
|
|
2
|
+
|
|
3
|
+
Supports DirectX shader syntax including cbuffer, tbuffer, struct, interface,
|
|
4
|
+
class (SM5), function semantic annotations (: SV_TARGET), and register() bindings.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import re
|
|
10
|
+
|
|
11
|
+
from ..configs import LanguageConfig
|
|
12
|
+
|
|
13
|
+
_NEVER_MATCH = re.compile(r"(?!x)x")
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def make_hlsl_language() -> LanguageConfig:
|
|
17
|
+
"""HLSL language configuration — C-like shader language for DirectX."""
|
|
18
|
+
return LanguageConfig(
|
|
19
|
+
name="hlsl",
|
|
20
|
+
# struct + SM5 interface/class (group 3 = optional inheritance base)
|
|
21
|
+
class_re=re.compile(
|
|
22
|
+
r"(?:^|\s)(struct|interface|class)\s+"
|
|
23
|
+
r"(\w+)"
|
|
24
|
+
r"\s*(?::\s*(\w+))?",
|
|
25
|
+
),
|
|
26
|
+
enum_re=re.compile(r"\benum\s+(\w+)"),
|
|
27
|
+
# No namespaces in HLSL
|
|
28
|
+
namespace_re=_NEVER_MATCH,
|
|
29
|
+
# Must tolerate trailing : SEMANTIC after closing paren
|
|
30
|
+
func_name_re=re.compile(r"(\w+)\s*\([^)]*\)\s*(?::\s*\w+\s*)?$"),
|
|
31
|
+
# No export macros
|
|
32
|
+
export_macro_re=_NEVER_MATCH,
|
|
33
|
+
# No calling conventions
|
|
34
|
+
calling_conv_re=_NEVER_MATCH,
|
|
35
|
+
# Strip register() and packoffset() binding annotations
|
|
36
|
+
attribute_re=re.compile(
|
|
37
|
+
r"\b(?:register|packoffset)\s*\([^)]*\)"
|
|
38
|
+
),
|
|
39
|
+
# No templates
|
|
40
|
+
template_re=_NEVER_MATCH,
|
|
41
|
+
# No destructors
|
|
42
|
+
dtor_re=_NEVER_MATCH,
|
|
43
|
+
control_flow_re=re.compile(r"\b(if|else\s+if|else|while|for|do|switch)\b"),
|
|
44
|
+
control_flow_names=frozenset({
|
|
45
|
+
"if", "else", "while", "for", "do", "switch",
|
|
46
|
+
"return", "break", "continue", "discard",
|
|
47
|
+
}),
|
|
48
|
+
trailing_mods_re=re.compile(
|
|
49
|
+
r"\s*(?:const|inline|static)\s*[;{]*\s*$"
|
|
50
|
+
),
|
|
51
|
+
# No access specifiers
|
|
52
|
+
access_spec_re=_NEVER_MATCH,
|
|
53
|
+
macro_like_re=re.compile(r"^[A-Z][A-Z0-9_]*\s*(?:\([^{};]*\))?\s*$"),
|
|
54
|
+
define_re=re.compile(r"#\s*define\s+"),
|
|
55
|
+
# No extern "C"
|
|
56
|
+
extern_c_re=_NEVER_MATCH,
|
|
57
|
+
# No operator overloading
|
|
58
|
+
operator_re=None,
|
|
59
|
+
uses_braces=True,
|
|
60
|
+
uses_namespaces=False,
|
|
61
|
+
uses_colon_inheritance=True,
|
|
62
|
+
# Edge extraction
|
|
63
|
+
scope_operator="::",
|
|
64
|
+
base_keyword="",
|
|
65
|
+
static_call_re=None,
|
|
66
|
+
super_call_re=None,
|
|
67
|
+
# PascalCase types (Texture2D, SamplerState, user-defined structs)
|
|
68
|
+
type_re=re.compile(r"\b([A-Z][A-Za-z0-9_]+)\b"),
|
|
69
|
+
param_type_re=re.compile(
|
|
70
|
+
r"(?:const\s+)?([A-Z][A-Za-z0-9_]+)\s+(?:\*+|&)?\s*\w+"
|
|
71
|
+
),
|
|
72
|
+
basic_skip_types=frozenset({
|
|
73
|
+
# Scalar types
|
|
74
|
+
"int", "uint", "float", "half", "double", "bool", "void", "dword",
|
|
75
|
+
# Vector types
|
|
76
|
+
"int2", "int3", "int4", "uint2", "uint3", "uint4",
|
|
77
|
+
"float2", "float3", "float4",
|
|
78
|
+
"half2", "half3", "half4",
|
|
79
|
+
"bool2", "bool3", "bool4",
|
|
80
|
+
"double2", "double3", "double4",
|
|
81
|
+
# Matrix types
|
|
82
|
+
"float2x2", "float2x3", "float2x4",
|
|
83
|
+
"float3x2", "float3x3", "float3x4",
|
|
84
|
+
"float4x2", "float4x3", "float4x4",
|
|
85
|
+
"int2x2", "int3x3", "int4x4",
|
|
86
|
+
# Sampler types
|
|
87
|
+
"SamplerState", "SamplerComparisonState",
|
|
88
|
+
# Texture types
|
|
89
|
+
"Texture1D", "Texture2D", "Texture3D", "TextureCube",
|
|
90
|
+
"Texture1DArray", "Texture2DArray", "TextureCubeArray",
|
|
91
|
+
"Texture2DMS", "Texture2DMSArray",
|
|
92
|
+
"RWTexture1D", "RWTexture2D", "RWTexture3D",
|
|
93
|
+
"RWTexture1DArray", "RWTexture2DArray",
|
|
94
|
+
# Buffer types
|
|
95
|
+
"Buffer", "RWBuffer",
|
|
96
|
+
"StructuredBuffer", "RWStructuredBuffer",
|
|
97
|
+
"ByteAddressBuffer", "RWByteAddressBuffer",
|
|
98
|
+
"AppendStructuredBuffer", "ConsumeStructuredBuffer",
|
|
99
|
+
# Parameter modifiers
|
|
100
|
+
"in", "out", "inout", "uniform",
|
|
101
|
+
}),
|
|
102
|
+
# Block classification helpers
|
|
103
|
+
block_keyword_re=re.compile(
|
|
104
|
+
r"\b(?:cbuffer|tbuffer|struct|interface|class|enum)\b"
|
|
105
|
+
),
|
|
106
|
+
# No lambdas
|
|
107
|
+
lambda_re=None,
|
|
108
|
+
# cbuffer/tbuffer recognized as namespace-like blocks
|
|
109
|
+
# attribute_re already stripped register(b0), leaving optional trailing ":"
|
|
110
|
+
namespace_sig_re=re.compile(
|
|
111
|
+
r"(?:cbuffer|tbuffer)\s+(\w+)\s*(?::\s*)?$"
|
|
112
|
+
),
|
|
113
|
+
init_list_re=None,
|
|
114
|
+
# View / summary helpers
|
|
115
|
+
access_spec_names=frozenset(),
|
|
116
|
+
view_structural_kws=("struct ", "cbuffer ", "tbuffer ", "interface ", "class "),
|
|
117
|
+
view_modifier_kws=("static ", "inline "),
|
|
118
|
+
local_var_modifiers="const|static|uniform|volatile",
|
|
119
|
+
# Bracket scanner hints
|
|
120
|
+
verbatim_string_prefix=None,
|
|
121
|
+
raw_string_char=None,
|
|
122
|
+
# No range-based for in HLSL
|
|
123
|
+
range_for_re=None,
|
|
124
|
+
# Comment syntax (same as C)
|
|
125
|
+
line_comment="//",
|
|
126
|
+
block_comment_pair=("/*", "*/"),
|
|
127
|
+
# String syntax — only double-quoted strings in HLSL
|
|
128
|
+
string_delimiters=frozenset({'"'}),
|
|
129
|
+
string_escape_char="\\",
|
|
130
|
+
triple_quote_strings=(),
|
|
131
|
+
# Block style
|
|
132
|
+
uses_indent_blocks=False,
|
|
133
|
+
# Preprocessor
|
|
134
|
+
preprocessor_prefix="#",
|
|
135
|
+
has_preprocessor_macros=True,
|
|
136
|
+
# Statement / block close
|
|
137
|
+
statement_terminator=";",
|
|
138
|
+
block_close_suffix="};",
|
|
139
|
+
summary_comment_prefix="//",
|
|
140
|
+
# Config-driven control flow
|
|
141
|
+
control_flow_patterns=(
|
|
142
|
+
("for", re.compile(r"^\s*for\s*\((.{1,80})\)\s*\{?\s*$")),
|
|
143
|
+
("while", re.compile(r"^\s*while\s*\((.{1,80})\)\s*\{?\s*$")),
|
|
144
|
+
("if", re.compile(r"^\s*(?:else\s+)?if\s*\((.{1,80})\)\s*\{?\s*$")),
|
|
145
|
+
("switch", re.compile(r"^\s*switch\s*\((.{1,40})\)\s*\{?\s*$")),
|
|
146
|
+
),
|
|
147
|
+
return_re=re.compile(r"^\s*return\s+(.{1,60});"),
|
|
148
|
+
# Extra syntax hints
|
|
149
|
+
type_indicator_chars="",
|
|
150
|
+
define_line_re=re.compile(r"#\s*define\s+(\w+)(\([^)]*\))?\s*(.*)"),
|
|
151
|
+
has_template_strings=False,
|
|
152
|
+
raw_string_style="cpp",
|
|
153
|
+
# Function signature end — matches ) : SEMANTIC_NAME (HLSL semantic annotations)
|
|
154
|
+
func_sig_end_re=re.compile(r"\)\s*(?::\s*\w+\s*)?$"),
|
|
155
|
+
)
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"""Java language configuration."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import re
|
|
6
|
+
|
|
7
|
+
from ..configs import LanguageConfig
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def make_java_language() -> LanguageConfig:
|
|
11
|
+
"""Java language configuration."""
|
|
12
|
+
return LanguageConfig(
|
|
13
|
+
name="java",
|
|
14
|
+
class_re=re.compile(
|
|
15
|
+
r"(?:^|\s)(?:(?:public|private|protected|abstract|final|static)\s+)*"
|
|
16
|
+
r"(class|interface|enum)\s+(\w+)"
|
|
17
|
+
r"(?:\s+extends\s+(\w+))?"
|
|
18
|
+
),
|
|
19
|
+
enum_re=re.compile(r"\benum\s+(\w+)"),
|
|
20
|
+
namespace_re=re.compile(r"(?!x)x"), # never-match; Java packages are directory-based
|
|
21
|
+
func_name_re=re.compile(
|
|
22
|
+
r"(\w+)\s*\([^)]*\)\s*(?:throws\s+[\w,\s]+)?\s*\{?\s*$"
|
|
23
|
+
),
|
|
24
|
+
export_macro_re=re.compile(r"(?!x)x"),
|
|
25
|
+
calling_conv_re=re.compile(r"(?!x)x"),
|
|
26
|
+
attribute_re=re.compile(r"@\w+(?:\.\w+)*(?:\([^)]*\))?"), # annotations
|
|
27
|
+
template_re=re.compile(r"<[^<>]*>"), # generics
|
|
28
|
+
dtor_re=re.compile(r"(?!x)x"),
|
|
29
|
+
control_flow_re=re.compile(r"\b(if|else\s+if|else|while|for|do|switch|catch|try|synchronized)\b"),
|
|
30
|
+
control_flow_names=frozenset({
|
|
31
|
+
"if", "else", "while", "for", "do", "switch", "catch", "try",
|
|
32
|
+
"return", "break", "continue", "throw", "synchronized", "assert", "new",
|
|
33
|
+
}),
|
|
34
|
+
trailing_mods_re=re.compile(r"\s*(?:throws\s+[\w,\s]+)?\s*\{?\s*$"),
|
|
35
|
+
access_spec_re=re.compile(r"(?!x)x"), # Java has no standalone access-spec lines
|
|
36
|
+
macro_like_re=re.compile(r"(?!x)x"),
|
|
37
|
+
define_re=re.compile(r"(?!x)x"),
|
|
38
|
+
extern_c_re=re.compile(r"(?!x)x"),
|
|
39
|
+
operator_re=None,
|
|
40
|
+
uses_braces=True,
|
|
41
|
+
uses_namespaces=False,
|
|
42
|
+
uses_colon_inheritance=True,
|
|
43
|
+
scope_operator=".",
|
|
44
|
+
base_keyword="super",
|
|
45
|
+
static_call_re=re.compile(r"\b([A-Z][A-Za-z0-9_]+)\.([A-Za-z_][A-Za-z0-9_]*)\s*\("),
|
|
46
|
+
super_call_re=re.compile(r"\bsuper\.([A-Za-z_][A-Za-z0-9_]*)\s*\("),
|
|
47
|
+
type_re=re.compile(r"\b([A-Z][A-Za-z0-9_]+)\b"),
|
|
48
|
+
param_type_re=re.compile(
|
|
49
|
+
r"([A-Z][A-Za-z0-9_]+)\s*<[^>]*>\s+\w+|([A-Z][A-Za-z0-9_]+)\s+\w+"
|
|
50
|
+
),
|
|
51
|
+
basic_skip_types=frozenset({
|
|
52
|
+
"int", "long", "short", "byte", "float", "double", "boolean", "char", "void",
|
|
53
|
+
"String", "Object", "Integer", "Long", "Double", "Float", "Boolean", "Byte",
|
|
54
|
+
"Short", "Character",
|
|
55
|
+
}),
|
|
56
|
+
block_keyword_re=re.compile(r"\b(?:class|interface|enum)\b"),
|
|
57
|
+
lambda_re=re.compile(r"->"), # Java lambdas
|
|
58
|
+
namespace_sig_re=None,
|
|
59
|
+
init_list_re=None,
|
|
60
|
+
access_spec_names=frozenset(),
|
|
61
|
+
view_structural_kws=("class ", "interface ", "enum "),
|
|
62
|
+
view_modifier_kws=("abstract ", "static ", "final ", "synchronized "),
|
|
63
|
+
local_var_modifiers="final|static|volatile|transient",
|
|
64
|
+
verbatim_string_prefix=None,
|
|
65
|
+
raw_string_char=None,
|
|
66
|
+
range_for_re=re.compile(
|
|
67
|
+
r"for\s*\(\s*(\w+(?:<[^>]*>)?)\s+(\w+)\s*:\s*(\w+)"
|
|
68
|
+
),
|
|
69
|
+
# Comment syntax
|
|
70
|
+
line_comment="//",
|
|
71
|
+
block_comment_pair=("/*", "*/"),
|
|
72
|
+
# String syntax
|
|
73
|
+
string_delimiters=frozenset({'"'}),
|
|
74
|
+
string_escape_char="\\",
|
|
75
|
+
triple_quote_strings=(),
|
|
76
|
+
# Block style
|
|
77
|
+
uses_indent_blocks=False,
|
|
78
|
+
# Preprocessor
|
|
79
|
+
preprocessor_prefix="",
|
|
80
|
+
has_preprocessor_macros=False,
|
|
81
|
+
# Statement / block close
|
|
82
|
+
statement_terminator=";",
|
|
83
|
+
block_close_suffix="}",
|
|
84
|
+
summary_comment_prefix="//",
|
|
85
|
+
# Config-driven control flow
|
|
86
|
+
control_flow_patterns=(
|
|
87
|
+
("for", re.compile(r"^\s*for\s*\((.{1,80})\)\s*\{?\s*$")),
|
|
88
|
+
("while", re.compile(r"^\s*while\s*\((.{1,80})\)\s*\{?\s*$")),
|
|
89
|
+
("if", re.compile(r"^\s*(?:else\s+)?if\s*\((.{1,80})\)\s*\{?\s*$")),
|
|
90
|
+
("switch", re.compile(r"^\s*switch\s*\((.{1,40})\)\s*\{?\s*$")),
|
|
91
|
+
),
|
|
92
|
+
return_re=re.compile(r"^\s*return\s+(.{1,60});"),
|
|
93
|
+
# Extra syntax hints
|
|
94
|
+
type_indicator_chars="",
|
|
95
|
+
define_line_re=None,
|
|
96
|
+
has_template_strings=False,
|
|
97
|
+
raw_string_style="cpp",
|
|
98
|
+
)
|