Skip to content

Commit

Permalink
Refactor AST code in ShaderLab for performance (#2486)
Browse files Browse the repository at this point in the history
* refactor(shaderlab): opt ast
  • Loading branch information
Sway007 authored Feb 18, 2025
1 parent 338b1e1 commit 8695423
Show file tree
Hide file tree
Showing 5 changed files with 342 additions and 300 deletions.
4 changes: 2 additions & 2 deletions packages/shader-lab/src/lalr/CFG.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Grammar } from "../parser/Grammar";
import { NoneTerminal, GrammarSymbol } from "../parser/GrammarSymbol";
import GrammarUtils from "./Utils";
import { EKeyword, ETokenType } from "../common";
import SematicAnalyzer, { TranslationRule } from "../parser/SemanticAnalyzer";
import SemanticAnalyzer, { TranslationRule } from "../parser/SemanticAnalyzer";
import { ASTNode } from "../parser/AST";

const productionAndRules: [GrammarSymbol[], TranslationRule | undefined][] = [
Expand Down Expand Up @@ -849,7 +849,7 @@ const createGrammar = () =>
productionAndRules.map((item) => item[0])
);

const addTranslationRule = (sa: SematicAnalyzer) => {
const addTranslationRule = (sa: SemanticAnalyzer) => {
for (let i = 0; i < productionAndRules.length; i++) {
const rule = productionAndRules[i][1];
if (rule) {
Expand Down
2 changes: 1 addition & 1 deletion packages/shader-lab/src/lexer/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default class LexerUtils {
);
}

static isPpCharactors(charCode: number) {
static isPpCharacters(charCode: number) {
return (
charCode === 35 || // #
charCode === 46 || // .
Expand Down
Loading

0 comments on commit 8695423

Please sign in to comment.