-
-
Notifications
You must be signed in to change notification settings - Fork 309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ShaderLab support variable list declaration. #2465
base: dev/1.4
Are you sure you want to change the base?
Conversation
WalkthroughThis pull request introduces enhancements to the shader language parser, focusing on variable declaration syntax and token handling. The changes span multiple files within the shader-lab package, including modifications to the context-free grammar, abstract syntax tree (AST), and parser rules. The primary objectives include adding a new semicolon token, refining variable declaration parsing, and introducing more flexible declaration list handling. These modifications improve the shader language's parsing capabilities and provide more structured approach to variable declarations. Changes
Sequence DiagramsequenceDiagram
participant Parser
participant AST
participant Grammar
participant Scanner
Parser->>Grammar: Define variable declaration rules
Grammar->>Parser: Confirm rule structure
Parser->>Scanner: Tokenize source code
Scanner->>Parser: Return tokens
Parser->>AST: Create Abstract Syntax Tree
AST->>Parser: Validate variable declarations
Possibly related PRs
Suggested Labels
Suggested Reviewers
Poem
Tip CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev/1.4 #2465 +/- ##
===========================================
+ Coverage 68.43% 68.47% +0.04%
===========================================
Files 922 922
Lines 95661 95716 +55
Branches 8121 8131 +10
===========================================
+ Hits 65466 65545 +79
+ Misses 29942 29918 -24
Partials 253 253
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🔭 Outside diff range comments (1)
packages/shader-lab/src/codeGen/GLES300.ts (1)
gl_FragColor
translation appears incompleteThe verification reveals potential issues with the
gl_FragColor
translation:
- While
GS_glFragColor
is defined as a constant, there's no evidence of it being properly declared as an output variable in fragment shaders- The codebase shows
gl_FragColor
is registered as a builtin variable, but the complete translation mechanism to GLSL ES 3.0's required output declaration is not visible- No
out vec4
declarations were found that would indicate proper fragment shader output handlingPoints requiring attention:
- Need to ensure
GS_glFragColor
is properly declared asout vec4
at the top of fragment shaders- The translation mechanism should include both variable renaming and output declaration handling
🔗 Analysis chain
Line range hint
35-52
: Handlegl_FragColor
translation appropriately.The updated
visitVariableIdentifier
method now correctly handlesgl_FragColor
by mapping it toGS_glFragColor
and adding it to the_referencedVaryingList
when in the fragment shader stage. This ensures compatibility with GLSL ES 3.0 standards.Run the following script to ensure that
gl_FragColor
is consistently handled across the codebase:
Let me gather more context about how
gl_FragColor
is handled in the codebase.
Let me check one more aspect to see how the fragment shader output is handled in GLES300.
Let me try one final verification with corrected commands.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that `gl_FragColor` is properly mapped and used. # Test: Search for usage of `gl_FragColor` and `GS_glFragColor`. rg 'gl_FragColor|GS_glFragColor' packages/shader-lab/src/Length of output: 425
Script:
#!/bin/bash # Check the implementation of visitVariableIdentifier in GLES300.ts ast-grep --pattern 'visitVariableIdentifier($_) { $$$ }' # Check if GS_glFragColor is properly declared as an output variable rg -A 5 'GS_glFragColor' packages/shader-lab/src/Length of output: 560
Script:
#!/bin/bash # Check for fragment shader output handling ast-grep --pattern 'override visitVariableIdentifier(node: $_) { $$$ }' # Check for any output declarations in fragment shaders rg -B 2 -A 5 'precision.*?;\s*\n.*?out\s+vec4' packages/shader-lab/src/Length of output: 341
Script:
#!/bin/bash # Check for fragment shader output handling ast-grep --pattern 'override visitVariableIdentifier(node: $_) { $$$ }' packages/shader-lab/src/codeGen/GLES300.ts # Check for output declarations in fragment shaders rg -U 'out\s+vec4' packages/shader-lab/src/ # Check how gl_FragColor is initialized rg -B 2 -A 2 'GS_glFragColor' packages/shader-lab/src/codeGen/Length of output: 578
🧹 Nitpick comments (2)
packages/shader-lab/src/parser/AST.ts (1)
237-253
: Fix the typo in variable namevariableDeclation
.In the
semanticAnalyze
method ofVariableDeclarationList
, the variablevariableDeclation
is misspelled. The correct spelling should bevariableDeclaration
. This typo may lead to confusion and could affect code readability and maintainability.Apply this diff to correct the typo:
- const variableDeclation = children[0] as VariableDeclaration; + const variableDeclaration = children[0] as VariableDeclaration;packages/shader-lab/src/lalr/CFG.ts (1)
33-45
: LGTM! Consider adding grammar documentation.The new rules for variable_declaration_list and variable_declaration_statement are well-structured and correctly implement the list declaration syntax. They properly handle both simple variables and array declarations.
Consider adding comments to document the grammar rules, especially the new list declaration syntax. For example:
+// Grammar rule for comma-separated variable declarations ...GrammarUtils.createProductionWithOptions( ENonTerminal.variable_declaration_list, [ [ENonTerminal.variable_declaration], [ENonTerminal.variable_declaration_list, ETokenType.COMMA, ETokenType.ID], [ENonTerminal.variable_declaration_list, ETokenType.COMMA, ETokenType.ID, ENonTerminal.array_specifier] ], ASTNode.VariableDeclarationList.pool ),
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
tests/src/shader-lab/shaders/demo.shader
is excluded by!**/*.shader
📒 Files selected for processing (10)
packages/shader-lab/src/codeGen/CodeGenVisitor.ts
(1 hunks)packages/shader-lab/src/codeGen/GLES300.ts
(1 hunks)packages/shader-lab/src/common/types.ts
(1 hunks)packages/shader-lab/src/lalr/CFG.ts
(1 hunks)packages/shader-lab/src/lalr/Utils.ts
(0 hunks)packages/shader-lab/src/parser/AST.ts
(3 hunks)packages/shader-lab/src/parser/GrammarSymbol.ts
(1 hunks)packages/shader-lab/src/parser/SemanticAnalyzer.ts
(2 hunks)packages/shader-lab/src/parser/TargetParser.y
(1 hunks)packages/shader-lab/src/parser/builtin/functions.ts
(1 hunks)
💤 Files with no reviewable changes (1)
- packages/shader-lab/src/lalr/Utils.ts
🧰 Additional context used
🪛 Biome (1.9.4)
packages/shader-lab/src/parser/SemanticAnalyzer.ts
[error] 73-73: This code is unreachable
... because this statement will return from the function beforehand
(lint/correctness/noUnreachable)
🔇 Additional comments (15)
packages/shader-lab/src/parser/AST.ts (3)
248-251
: Confirm error handling for arrays of arrays.
In the error handling logic, the code checks for arrays of arrays and triggers an error if both arraySpecifier
and this.arraySpecifier
are present. Ensure that this logic correctly identifies and handles such cases, and verify that the error message is informative and aligns with user expectations.
390-392
: Accessor method arraySpecifier
appears correct.
The addition of the arraySpecifier
getter in the TypeSpecifier
class correctly returns the expected child node as an ArraySpecifier
. This enhances code readability and maintainability.
1421-1423
: Ensure consistent semicolon handling in code generation.
In the codeGen
method of VariableDeclaration
, a semicolon is appended to the result of visitor.visitVariableDeclaration(this)
. Verify that visitor.visitVariableDeclaration
does not already include a semicolon to prevent double semicolons in the generated code.
Run the following script to check for duplicate semicolons in the code generation:
✅ Verification successful
Let me check the visitor implementation to see how it handles variable declarations.
Let me try a different approach to find the visitor implementation.
Let me check the implementation of visitVariableDeclaration in CodeGenVisitor.ts.
No double semicolon issue found in variable declaration code generation
The implementation shows that visitVariableDeclaration
in CodeGenVisitor
uses defaultCodeGen
which simply concatenates the code from child nodes without adding any semicolons. The semicolon is only added once in the codeGen
method of the VariableDeclaration
AST node, so there's no risk of duplicate semicolons.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Search for instances where semicolons may be duplicated in variable declarations.
# Test: Look for ';;' patterns resulting from concatenation.
rg -A 2 -B 2 $'visitVariableDeclaration\(this\).+;'
Length of output: 368
Script:
#!/bin/bash
# Search for visitVariableDeclaration implementation in the codebase
ast-grep --pattern 'visitVariableDeclaration($_) {
$$$
}'
Length of output: 61
Script:
#!/bin/bash
# Search for CodeGenVisitor class and its implementation
rg -A 10 "class.*CodeGenVisitor"
# Also search for any file containing visitVariableDeclaration
fd -e ts -e js -x rg -l "visitVariableDeclaration"
Length of output: 2013
Script:
#!/bin/bash
# Search for visitVariableDeclaration implementation in CodeGenVisitor
rg -A 10 "visitVariableDeclaration" packages/shader-lab/src/codeGen/CodeGenVisitor.ts
Length of output: 537
packages/shader-lab/src/parser/SemanticAnalyzer.ts (2)
27-27
: Update the errors
property documentation and usage.
The errors
property type has been updated from GSError[]
to Error[]
. Ensure that all references and handling of this property throughout the codebase are updated accordingly to reflect the new type.
73-73
: Align with static analysis tool recommendations.
Static analysis indicates that the code at line 73 is unreachable. Review the conditional compilation directives to ensure that the code is reachable and functions as intended.
Run the following script to identify unreachable code within the file:
🧰 Tools
🪛 Biome (1.9.4)
[error] 73-73: This code is unreachable
... because this statement will return from the function beforehand
(lint/correctness/noUnreachable)
packages/shader-lab/src/parser/GrammarSymbol.ts (1)
13-14
: New enum members are properly added to ENonTerminal
.
The addition of variable_declaration_list
and variable_declaration_statement
to the ENonTerminal
enum enhances the grammar's ability to handle variable declarations. Ensure that these new symbols are integrated consistently throughout the parser and that all related parsing logic is updated accordingly.
packages/shader-lab/src/codeGen/GLES300.ts (1)
4-4
: Unused import ShaderPosition
has been correctly removed.
The removal of the unused import statement for ShaderPosition
cleans up the code and eliminates unnecessary dependencies, improving maintainability.
packages/shader-lab/src/common/types.ts (1)
135-135
: LGTM! Addition of SEMICOLON token
The addition of the SEMICOLON token is well-documented and properly placed within the enum, supporting the new variable list declaration syntax.
packages/shader-lab/src/codeGen/CodeGenVisitor.ts (1)
Line range hint 128-133
: LGTM! Method rename improves flexibility
The rename from visitGlobalVariableDeclaration
to visitVariableDeclaration
makes the method more generic while maintaining its functionality.
Let's verify that all callers have been updated to use the new method name:
✅ Verification successful
Method rename is correctly implemented and all references are updated
The verification shows that:
- No references to the old method name
visitGlobalVariableDeclaration
exist in the codebase - The new method name
visitVariableDeclaration
is properly used in both:- The implementation file (
CodeGenVisitor.ts
) - The AST definition file (
AST.ts
) where it's being called
- The implementation file (
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for any remaining references to the old method name
rg "visitGlobalVariableDeclaration" -l
# Search for references to the new method name to ensure it's being used
rg "visitVariableDeclaration" -A 2
Length of output: 613
packages/shader-lab/src/parser/TargetParser.y (2)
77-81
: LGTM! Well-structured variable list declaration rule
The new variable_declaration_list
rule correctly implements the comma-separated list syntax, supporting both simple identifiers and array declarations. This enables the target syntax: vec2 weights[2], offsets[2];
67-67
: LGTM! Clean grammar restructuring
The grammar changes are well-organized:
- Separated core variable declaration from statement termination
- Made variable declarations reusable in lists
- Properly integrated with global declarations
Let's verify the grammar doesn't introduce any conflicts:
Also applies to: 72-74, 83-84
✅ Verification successful
The previous attempt failed because we couldn't locate the parser output file. Let's try to understand the grammar structure and potential conflicts by examining the grammar files directly. This will help us verify if the variable declaration changes are properly integrated.
The previous output showed multiple grammar files but we need to specifically examine the variable declaration rules and their integration with other productions to verify the grammar structure. Let's analyze the specific grammar rules and any potential conflict resolution directives.
Grammar structure verified - no conflicts detected
The grammar changes for variable declarations are well-structured and safe:
- Variable declarations follow a clear hierarchical structure:
variable_declaration
defines basic form (type + id + optional array)variable_declaration_list
allows comma-separated declarationsvariable_declaration_statement
properly terminates with semicolon
- Integration points are clean:
- Used in
global_declaration
without ambiguity - Separate from but compatible with struct declarations
- Properly integrated with statement and declaration productions
- Used in
The grammar restructuring maintains a clear separation of concerns and follows standard parser design patterns without introducing ambiguity in the productions.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for any shift/reduce or reduce/reduce conflicts in the grammar
rg "conflict|warning" packages/shader-lab/src/parser/TargetParser.output
# Check for any error handling related to the new syntax
rg "error.*variable_declaration" -A 2
Length of output: 205
Script:
#!/bin/bash
# First, let's check if the parser output file exists in a different location
fd TargetParser.output
# Let's examine the build process to see where parser outputs might be generated
fd -e y -e yacc -e grammar --exec cat {} \; | grep -i "output"
# Let's check for any existing grammar files and their content
fd -e y -e yacc -e grammar --exec head -n 20 {} \;
Length of output: 1090
Script:
#!/bin/bash
# Let's examine the grammar file content more specifically around variable declarations
rg -A 5 -B 5 "variable_declaration" packages/shader-lab/src/parser/TargetParser.y
# Let's also check for any related productions and rules
rg "statement|declaration" packages/shader-lab/src/parser/TargetParser.y
# Check if there are any error productions or conflict resolution directives
rg "%prec|%left|%right|%nonassoc|error" packages/shader-lab/src/parser/TargetParser.y
Length of output: 2369
packages/shader-lab/src/parser/builtin/functions.ts (2)
295-295
: LGTM! Function signature matches GLSL spec.
The textureCubeLodEXT function is correctly defined with appropriate parameter types (GSamplerCube, VEC3, FLOAT) and return value (GVec4).
289-290
: LGTM! Verify WebGL extension availability.
The texture2DLodEXT functions are correctly defined with appropriate parameter types and return values. These functions are typically part of the GL_EXT_shader_texture_lod extension.
✅ Verification successful
Extension dependency is properly handled
The texture2DLodEXT functions are correctly supported as the GL_EXT_shader_texture_lod extension is already enabled in both the shader-lab and core packages:
- packages/shader-lab/src/codeGen/GLES100.ts
- packages/core/src/shaderlib/ShaderFactory.ts
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for extension enabling code
rg -A 2 "GL_EXT_shader_texture_lod|WEBGL_shader_texture_lod"
Length of output: 519
packages/shader-lab/src/lalr/CFG.ts (2)
19-19
: LGTM! Grammar rule updated for variable list support.
The change from variable_declaration
to variable_declaration_statement
aligns with the PR objective to support variable list declarations.
27-28
: LGTM! Variable declaration rule properly decomposed.
The variable_declaration rule has been correctly simplified to handle basic declaration components, allowing it to be used within a variable list. The semicolon is appropriately moved to the statement level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (3)
packages/shader-lab/src/parser/SemanticAnalyzer.ts (1)
28-28
: Consider implications of broadening error type.The change from
GSError[]
toError[]
makes the error collection more generic, but might lose shader-specific error information. Consider using a union typeArray<GSError | Error>
to maintain type safety while allowing flexibility.packages/shader-lab/src/parser/AST.ts (2)
237-253
: Enhance error message for array validation.While the array validation is good, the error message could be more descriptive to help developers understand the limitations and alternatives.
- sa.error(arraySpecifier.location, "Array of array is not supported."); + sa.error(arraySpecifier.location, "Nested arrays (array of arrays) are not supported in ShaderLab. Consider using a single array with a larger size.");
1405-1422
: Consider moving semicolon handling to the visitor.The semicolon appending in codeGen might be better handled in the visitor to maintain consistent statement termination across all AST nodes.
- return visitor.visitVariableDeclaration(this) + ";"; + return visitor.visitVariableDeclaration(this);Then handle the semicolon in the visitor:
visitVariableDeclaration(node: VariableDeclaration): string { return this.generateVariableDeclaration(node) + ";"; }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
tests/src/shader-lab/shaders/demo.shader
is excluded by!**/*.shader
📒 Files selected for processing (3)
packages/shader-lab/src/common/BaseScanner.ts
(1 hunks)packages/shader-lab/src/parser/AST.ts
(6 hunks)packages/shader-lab/src/parser/SemanticAnalyzer.ts
(3 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
packages/shader-lab/src/parser/SemanticAnalyzer.ts
[error] 74-74: This code is unreachable
... because this statement will return from the function beforehand
(lint/correctness/noUnreachable)
🔇 Additional comments (2)
packages/shader-lab/src/parser/SemanticAnalyzer.ts (1)
68-76
:
Fix unreachable code in error handling.
The current implementation has unreachable code in non-verbose mode due to the conditional compilation structure.
Apply this diff to fix the issue:
error(loc: ShaderRange, message: string) {
// #if _VERBOSE
const err = new GSError(GSErrorName.CompilationError, message, loc, ShaderLab._processingPassText);
this.errors.push(err);
return err;
// #else
- Logger.error(message);
+ const err = new Error(message);
+ Logger.error(message);
+ return err;
// #endif
}
Likely invalid or redundant comment.
🧰 Tools
🪛 Biome (1.9.4)
[error] 74-74: This code is unreachable
... because this statement will return from the function beforehand
(lint/correctness/noUnreachable)
packages/shader-lab/src/common/BaseScanner.ts (1)
120-120
: LGTM! Improved safety in comment parsing.
The addition of !this.isEnd()
check is a crucial safety improvement that prevents infinite loops when parsing comments at the end of the source string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
packages/shader-lab/src/parser/AST.ts (2)
1126-1127
: Consider moving semicolon handling to the visitor.The semicolon is currently hardcoded in the
codeGen
method. Consider moving this responsibility to theCodeGenVisitor
for better separation of concerns.- return visitor.visitGlobalVariableDeclaration(this) + ";"; + return visitor.visitGlobalVariableDeclaration(this);Then update the visitor to handle semicolons consistently.
Also applies to: 1139-1141
1143-1169
: Well-structured implementation with good separation of concerns.The implementation nicely separates:
- Grammar rules (in TargetParser.y)
- AST node definitions (in AST.ts)
- Semantic analysis (in node classes)
- Code generation (via visitor pattern)
This makes the code maintainable and extensible.
Consider documenting the design decisions and validation rules in the README or developer documentation.
Also applies to: 75-86
🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 1163-1163: packages/shader-lab/src/parser/AST.ts#L1163
Added line #L1163 was not covered by tests
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
packages/shader-lab/src/common/BaseScanner.ts
(1 hunks)packages/shader-lab/src/common/types.ts
(1 hunks)packages/shader-lab/src/lalr/CFG.ts
(1 hunks)packages/shader-lab/src/parser/AST.ts
(3 hunks)packages/shader-lab/src/parser/GrammarSymbol.ts
(1 hunks)packages/shader-lab/src/parser/TargetParser.y
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
- packages/shader-lab/src/common/types.ts
- packages/shader-lab/src/lalr/CFG.ts
- packages/shader-lab/src/parser/GrammarSymbol.ts
- packages/shader-lab/src/common/BaseScanner.ts
🧰 Additional context used
🪛 GitHub Check: codecov/patch
packages/shader-lab/src/parser/AST.ts
[warning] 200-201: packages/shader-lab/src/parser/AST.ts#L200-L201
Added lines #L200 - L201 were not covered by tests
[warning] 1163-1163: packages/shader-lab/src/parser/AST.ts#L1163
Added line #L1163 was not covered by tests
🔇 Additional comments (4)
packages/shader-lab/src/parser/TargetParser.y (1)
69-69
: Grammar changes look good but need test coverage.
The grammar changes correctly implement variable list declarations with the following structure:
- Modified
global_declaration
to usevariable_declaration_statement
- Added support for comma-separated declarations via
variable_declaration_list
- Properly handles array specifiers
- Enforces semicolon termination
The implementation follows common shader language conventions, similar to GLSL.
Please ensure comprehensive test coverage for:
- Basic variable list declarations
- Array declarations in lists
- Error cases (e.g., mismatched types)
Also applies to: 75-76, 79-83, 85-86
✅ Verification successful
Let me check the test coverage in the identified files.
Let me try a different approach to check the test coverage.
Let me check the actual shader test files to see if they cover variable declarations.
Test coverage exists for variable declaration list syntax
Based on the analysis of the test files, particularly demo.shader
, there is test coverage for the new variable declaration list syntax. The file includes:
- Basic variable list declarations:
vec2 v1, v2[2], v3[3];
- Array declarations in lists with initialization:
vec2 weights[2], offsets[2];
- Error cases are covered in
compilation-error.shader
which tests the parser's error handling capabilities.
The test files demonstrate that the grammar changes for variable declarations are being exercised through the existing test suite, including:
- Comma-separated declarations
- Array specifiers
- Semicolon termination
- Various variable types and contexts
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for existing test files
fd -e test.ts -e spec.ts . | grep -i "shader\|variable\|declaration"
Length of output: 181
Script:
#!/bin/bash
# Check test content for variable declaration tests
echo "=== Checking Shader.test.ts ==="
rg -A 5 "variable.*declaration|test.*variable" tests/src/core/Shader.test.ts
echo -e "\n=== Checking Preprocessor.test.ts ==="
rg -A 5 "variable.*declaration|test.*variable" tests/src/shader-lab/Preprocessor.test.ts
echo -e "\n=== Checking ShaderLab.test.ts ==="
rg -A 5 "variable.*declaration|test.*variable" tests/src/shader-lab/ShaderLab.test.ts
# Look for parser test files that might have been missed
echo -e "\n=== Checking for parser test files ==="
fd -e test.ts -e spec.ts . | grep -i "parser"
Length of output: 645
Script:
#!/bin/bash
# Search for test files specifically in shader-lab package
echo "=== Checking for parser tests in shader-lab ==="
fd -e test.ts -e spec.ts . packages/shader-lab/
# Check content of ShaderLab.test.ts for any parser-related tests
echo -e "\n=== Content of ShaderLab.test.ts ==="
cat tests/src/shader-lab/ShaderLab.test.ts
# Look for test files containing "parser" in their content
echo -e "\n=== Files containing parser tests ==="
rg -l "describe.*['\"]Parser|test.*['\"]Parser" -g "*.test.ts" -g "*.spec.ts"
Length of output: 10107
Script:
#!/bin/bash
# Check the content of test shader files for variable declarations
echo "=== Checking test shader files ==="
# First, find the shader files
fd -e shader . tests/src/shader-lab/shaders/
# Then check content of a few key shader files that might contain variable declarations
echo -e "\n=== Content of demo.shader ==="
cat tests/src/shader-lab/shaders/demo.shader
echo -e "\n=== Content of compilation-error.shader ==="
cat tests/src/shader-lab/shaders/compilation-error.shader
Length of output: 8260
packages/shader-lab/src/parser/AST.ts (3)
181-187
: LGTM: SingleDeclaration changes handle array specifiers correctly.
The changes properly track and handle array specifiers in the type system.
199-201
: Add test coverage for array validation.
The array validation logic is important but lacks test coverage according to static analysis.
Please add tests for the array validation logic, particularly the "Array of array is not supported" error case.
🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 200-201: packages/shader-lab/src/parser/AST.ts#L200-L201
Added lines #L200 - L201 were not covered by tests
1143-1169
: Add type validation and improve test coverage.
The VariableDeclarationList implementation looks good but could be improved:
- Missing test coverage for variable list creation (line 1163)
- No type compatibility validation between variables in the list
Run the following to check existing test coverage:
#!/bin/bash
# Search for relevant test cases
rg -A 5 "VariableDeclarationList" . --type ts --type test
🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 1163-1163: packages/shader-lab/src/parser/AST.ts#L1163
Added line #L1163 was not covered by tests
Please check if the PR fulfills these requirements
What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
Support syntax of variable list declaration for global uniform and local variables:
Summary by CodeRabbit
New Features
SEMICOLON
for enhanced parsing.texture2DLodEXT
andtextureCubeLodEXT
for advanced texture sampling.Bug Fixes
Refactor