@galacean/engine-shader-compiler 2.0.0-alpha.52 → 2.0.0-alpha.53

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.
Files changed (91) hide show
  1. package/README.md +40 -4
  2. package/bundler/cli.js +199 -104
  3. package/bundler/precompile.cjs.js +117 -47
  4. package/bundler/precompile.js +117 -47
  5. package/bundler/rollup.cjs.js +115 -45
  6. package/bundler/rollup.js +115 -45
  7. package/dist/browser.js +13421 -6555
  8. package/dist/browser.js.map +1 -1
  9. package/dist/browser.min.js +1 -1
  10. package/dist/browser.min.js.map +1 -1
  11. package/dist/main.js +1758 -8450
  12. package/dist/main.js.map +1 -1
  13. package/dist/module.js +1730 -8427
  14. package/dist/module.js.map +1 -1
  15. package/dist/precompile.main.js +2280 -0
  16. package/dist/precompile.main.js.map +1 -0
  17. package/dist/precompile.module.js +2276 -0
  18. package/dist/precompile.module.js.map +1 -0
  19. package/package.json +24 -13
  20. package/types/GLESBackend.d.ts +22 -0
  21. package/types/ShaderBackend.d.ts +15 -0
  22. package/types/ShaderCompilation.d.ts +40 -0
  23. package/types/ShaderCompiler.d.ts +42 -14
  24. package/types/ShaderInstructionEncoder.d.ts +46 -14
  25. package/types/ShaderPrecompiler.d.ts +31 -0
  26. package/types/bundler/precompile.d.ts +26 -3
  27. package/types/bundler/rollup.d.ts +23 -2
  28. package/types/codeGen/CodeGenVisitor.d.ts +11 -6
  29. package/types/codeGen/GLES100.d.ts +3 -5
  30. package/types/codeGen/GLES300.d.ts +14 -7
  31. package/types/codeGen/GLESVisitor.d.ts +55 -9
  32. package/types/codeGen/VisitorContext.d.ts +88 -29
  33. package/types/codeGen/types.d.ts +1 -1
  34. package/types/index.d.ts +4 -1
  35. package/types/precompile.d.ts +1 -0
  36. package/dist/browser.verbose.js +0 -9601
  37. package/dist/browser.verbose.js.map +0 -1
  38. package/dist/browser.verbose.min.js +0 -2
  39. package/dist/browser.verbose.min.js.map +0 -1
  40. package/dist/main.verbose.js +0 -9598
  41. package/dist/main.verbose.js.map +0 -1
  42. package/dist/module.verbose.js +0 -9591
  43. package/dist/module.verbose.js.map +0 -1
  44. package/types/GSError.d.ts +0 -16
  45. package/types/ParserUtils.d.ts +0 -43
  46. package/types/Preprocessor.d.ts +0 -30
  47. package/types/ShaderCompilerUtils.d.ts +0 -10
  48. package/types/common/BaseLexer.d.ts +0 -51
  49. package/types/common/BaseToken.d.ts +0 -35
  50. package/types/common/IBaseSymbol.d.ts +0 -5
  51. package/types/common/ShaderPosition.d.ts +0 -8
  52. package/types/common/ShaderRange.d.ts +0 -8
  53. package/types/common/SymbolTable.d.ts +0 -13
  54. package/types/common/SymbolTableStack.d.ts +0 -17
  55. package/types/common/enums/Keyword.d.ts +0 -124
  56. package/types/common/enums/ShaderStage.d.ts +0 -5
  57. package/types/common/index.d.ts +0 -5
  58. package/types/common/types.d.ts +0 -101
  59. package/types/lalr/CFG.d.ts +0 -5
  60. package/types/lalr/LALR1.d.ts +0 -27
  61. package/types/lalr/Production.d.ts +0 -9
  62. package/types/lalr/State.d.ts +0 -20
  63. package/types/lalr/StateItem.d.ts +0 -20
  64. package/types/lalr/Utils.d.ts +0 -22
  65. package/types/lalr/index.d.ts +0 -2
  66. package/types/lalr/types.d.ts +0 -14
  67. package/types/lexer/Lexer.d.ts +0 -143
  68. package/types/lexer/index.d.ts +0 -1
  69. package/types/parser/AST.d.ts +0 -502
  70. package/types/parser/Grammar.d.ts +0 -11
  71. package/types/parser/GrammarSymbol.d.ts +0 -128
  72. package/types/parser/SemanticAnalyzer.d.ts +0 -42
  73. package/types/parser/ShaderInfo.d.ts +0 -10
  74. package/types/parser/ShaderTargetParser.d.ts +0 -26
  75. package/types/parser/builtin/functions.d.ts +0 -34
  76. package/types/parser/builtin/index.d.ts +0 -2
  77. package/types/parser/builtin/variables.d.ts +0 -11
  78. package/types/parser/index.d.ts +0 -2
  79. package/types/parser/symbolTable/FnSymbol.d.ts +0 -6
  80. package/types/parser/symbolTable/StructSymbol.d.ts +0 -6
  81. package/types/parser/symbolTable/SymbolDataType.d.ts +0 -8
  82. package/types/parser/symbolTable/SymbolInfo.d.ts +0 -22
  83. package/types/parser/symbolTable/VarSymbol.d.ts +0 -8
  84. package/types/parser/symbolTable/index.d.ts +0 -6
  85. package/types/parser/types.d.ts +0 -24
  86. package/types/sourceParser/ShaderSourceFactory.d.ts +0 -8
  87. package/types/sourceParser/ShaderSourceParser.d.ts +0 -30
  88. package/types/sourceParser/ShaderSourceSymbol.d.ts +0 -10
  89. package/types/sourceParser/SourceLexer.d.ts +0 -19
  90. package/types/sourceParser/index.d.ts +0 -1
  91. package/verbose/package.json +0 -10
@@ -1,16 +0,0 @@
1
- import { ShaderPosition } from "./common/ShaderPosition";
2
- import { ShaderRange } from "./common/ShaderRange";
3
- export declare class GSError extends Error {
4
- readonly location: ShaderRange | ShaderPosition;
5
- readonly source: string;
6
- readonly file?: string | undefined;
7
- static wrappingLineCount: number;
8
- constructor(name: GSErrorName, message: string, location: ShaderRange | ShaderPosition, source: string, file?: string | undefined);
9
- toString(): string;
10
- }
11
- export declare enum GSErrorName {
12
- PreprocessorError = "PreprocessorError",
13
- CompilationError = "CompilationError",
14
- ScannerError = "ScannerError",
15
- CompilationWarn = "CompilationWarning"
16
- }
@@ -1,43 +0,0 @@
1
- import { GalaceanDataType } from "./common";
2
- import { ASTNode, TreeNode } from "./parser/AST";
3
- import { GrammarSymbol, NoneTerminal } from "./parser/GrammarSymbol";
4
- export declare class ParserUtils {
5
- static unwrapNodeByType<T = TreeNode>(node: TreeNode, type: NoneTerminal): T | undefined;
6
- /**
7
- * Parse a function-macro parameter-list lexeme (`"(a, b, c)"`) into its parameter
8
- * names. An empty list `"()"` yields `[]`. Leading/trailing whitespace around each
9
- * name is trimmed. Empty entries from consecutive commas are filtered out.
10
- */
11
- static parseMacroParamList(lexeme: string): string[];
12
- /**
13
- * Walk single-child precedence-chain wrappers down to a `VariableIdentifier`,
14
- * returning the leaf node (or `undefined` for any compound expression).
15
- *
16
- * `allowParens` chooses between two callers' needs:
17
- * - `true` — descend through `( expression )` form, so `(v)` resolves to
18
- * `v`. Use when the caller substitutes at the expression root
19
- * (aliasing, renaming); user-written parens carry no extra meaning.
20
- * - `false` — any 3-child `PrimaryExpression` aborts; `(v)` stays
21
- * compound. Use when the caller treats the unwrapped node as a single
22
- * token (IO-struct arg drop, alias detection); user-written parens
23
- * must not collapse.
24
- */
25
- static unwrapBareIdentifier(node: TreeNode, options: {
26
- allowParens: boolean;
27
- }): ASTNode.VariableIdentifier | undefined;
28
- /**
29
- * Lexeme variant of `unwrapBareIdentifier({ allowParens: true })` for callers
30
- * that already work with strings. Returns `null` for compound expressions.
31
- */
32
- static extractDirectIdentLexeme(expr: TreeNode): string | null;
33
- /**
34
- * Check if type `tb` is compatible with type `ta`.
35
- */
36
- static typeCompatible(ta: GalaceanDataType, tb: GalaceanDataType | undefined): boolean;
37
- static toString(sm: GrammarSymbol): string;
38
- static isTerminal(sm: GrammarSymbol): boolean;
39
- /**
40
- * @internal
41
- */
42
- static printStatePool(logPath: string): void;
43
- }
@@ -1,30 +0,0 @@
1
- import type { ASTNode } from "./parser/AST";
2
- import type { BranchSignature } from "./common/BaseToken";
3
- export type IncludeMap = {
4
- readonly [includeName: string]: string | undefined;
5
- };
6
- export type ChunkOutputCache = Map<string, string>;
7
- export interface MacroDefineInfo {
8
- isFunction: boolean;
9
- params: string[];
10
- /** Value AST. Set when the replacement list parses as `expression` (which
11
- * includes comma-separated lists per C99 §6.10.3); absent for the GLSL ES
12
- * 3.00 §3.4 opaque cases the grammar can't reduce (empty, type-alias keyword,
13
- * trailing punctuation, unbalanced bracket, trailing operator). Identifier
14
- * references inside are collected by `MacroCallSymbol._collectIdentifierRefs`
15
- * walking this subtree. */
16
- valueAst?: ASTNode.Expression;
17
- /** Whitespace-normalized directive text. Dedup key against re-includes in
18
- * the same branch; differing values produce different keys. */
19
- dedupKey: string;
20
- /** `#ifdef` branch at registration time; call sites filter to visible entries. */
21
- branch: BranchSignature;
22
- }
23
- export interface MacroDefineList {
24
- [macroName: string]: MacroDefineInfo[];
25
- }
26
- export declare class Preprocessor {
27
- private static readonly _includeReg;
28
- static parse(source: string, basePathForIncludeKey: string, includeMap: IncludeMap, chunkOutputCache: ChunkOutputCache): string;
29
- private static _replace;
30
- }
@@ -1,10 +0,0 @@
1
- import { ClearableObjectPool, type IPoolElement } from "@galacean/engine-core";
2
- import { GSErrorName } from "./GSError";
3
- import { ShaderRange } from "./common/ShaderRange";
4
- import { ShaderPosition } from "./common/ShaderPosition";
5
- export declare class ShaderCompilerUtils {
6
- private static _shaderCompilerObjectPoolSet;
7
- static createObjectPool<T extends IPoolElement>(type: new () => T): ClearableObjectPool<T>;
8
- static clearAllShaderCompilerObjectPool(): void;
9
- static createGSError(message: string, errorName: GSErrorName, source: string, location: ShaderRange | ShaderPosition, file?: string): Error;
10
- }
@@ -1,51 +0,0 @@
1
- import { ShaderPosition, ShaderRange } from ".";
2
- import { BaseToken } from "./BaseToken";
3
- export type OnToken = (token: BaseToken, scanner: BaseLexer) => void;
4
- /**
5
- * @internal
6
- */
7
- export declare abstract class BaseLexer {
8
- static isDigit(charCode: number): boolean;
9
- static isHexDigit(charCode: number): boolean;
10
- static isAlpha(charCode: number): boolean;
11
- static isAlnum(charCode: number): boolean;
12
- static isPreprocessorStartChar(charCode: number): boolean;
13
- /**
14
- * If `i` points at the start of a `/* … *\/` block comment, return the index
15
- * just past the closing `*\/`. Otherwise return `i` unchanged. If the
16
- * comment is unterminated, returns `len` (clamped, never overshoots).
17
- * Single source of truth for block-comment scanning across the lexer.
18
- */
19
- protected static _skipBlockComment(src: string, i: number, len: number): number;
20
- /**
21
- * If `i` points at the start of a `//` line comment, return the index of the
22
- * terminating newline (or `len` at EOF). The newline itself is NOT consumed
23
- * — callers decide whether `\n` is whitespace or a logical separator.
24
- * Otherwise return `i` unchanged.
25
- */
26
- protected static _skipLineComment(src: string, i: number, len: number): number;
27
- static isWhiteSpaceChar(charCode: number, includeBreak: boolean): boolean;
28
- protected _currentIndex: number;
29
- protected _source: string;
30
- protected _column: number;
31
- protected _line: number;
32
- get currentIndex(): number;
33
- get source(): string;
34
- get line(): number;
35
- get column(): number;
36
- constructor(source?: string);
37
- setSource(source: string): void;
38
- getShaderPosition(backOffset?: number): ShaderPosition;
39
- isEnd(): boolean;
40
- getCurChar(): string;
41
- getCurCharCode(): number;
42
- advance(count: number): void;
43
- skipSpace(includeLineBreak: boolean): void;
44
- skipCommentsAndSpace(): void;
45
- peek(to: number): string;
46
- scanLexeme(lexeme: string): void;
47
- scanTwoExpectedLexemes(lexeme1: string, lexeme2: string): string | null;
48
- throwError(pos: ShaderPosition | ShaderRange, ...msgs: any[]): void;
49
- scanPairedChar(left: string, right: string, balanced: boolean, skipLeading: boolean): string;
50
- abstract scanToken(onToken?: OnToken): void;
51
- }
@@ -1,35 +0,0 @@
1
- import { ShaderRange, ShaderPosition } from ".";
2
- import type { IPoolElement } from "@galacean/engine-core";
3
- /**
4
- * One condition in a branch signature: `defined: true` for `#ifdef X` (the
5
- * branch is active when `X` is defined), `defined: false` for `#ifndef X` /
6
- * after `#else` (active when `X` is undefined).
7
- */
8
- export interface BranchConstraint {
9
- name: string;
10
- defined: boolean;
11
- }
12
- /**
13
- * Snapshot of the `#ifdef`/`#ifndef`/`#else` stack at a source position. An
14
- * empty signature means unconditional (top-level). Constraints are conjunctive:
15
- * the position is active iff every constraint holds. Produced by the Lexer
16
- * (the sole branch-stack maintainer) and stamped onto every emitted token +
17
- * every registered `MacroDefineInfo`.
18
- */
19
- export type BranchSignature = readonly BranchConstraint[];
20
- export declare const EMPTY_BRANCH: BranchSignature;
21
- export declare class BaseToken<T extends number = number> implements IPoolElement {
22
- static pool: import("@galacean/engine-core").ClearableObjectPool<BaseToken<number>>;
23
- type: T;
24
- lexeme: string;
25
- location: ShaderRange;
26
- /** Branch signature snapshot at the point this token was emitted. Empty
27
- * signature (default) means top-level / unconditional. The Lexer tags
28
- * every token; downstream code (AST nodes built from tokens) can read
29
- * the field directly to know which `#ifdef` branch they're inside. */
30
- branch: BranchSignature;
31
- set(type: T, lexeme: string, start?: ShaderPosition): any;
32
- set(type: T, lexeme: string, location?: ShaderRange): any;
33
- dispose(): void;
34
- }
35
- export declare const EOF: BaseToken<number>;
@@ -1,5 +0,0 @@
1
- export interface IBaseSymbol {
2
- isInMacroBranch: boolean;
3
- readonly ident: string;
4
- equal(other: IBaseSymbol): boolean;
5
- }
@@ -1,8 +0,0 @@
1
- import type { IPoolElement } from "@galacean/engine-core";
2
- export declare class ShaderPosition implements IPoolElement {
3
- index: number;
4
- line: number;
5
- column: number;
6
- set(index: number, line: number, column: number): void;
7
- dispose(): void;
8
- }
@@ -1,8 +0,0 @@
1
- import type { IPoolElement } from "@galacean/engine-core";
2
- import { ShaderPosition } from "./ShaderPosition";
3
- export declare class ShaderRange implements IPoolElement {
4
- start: ShaderPosition;
5
- end: ShaderPosition;
6
- set(start: ShaderPosition, end: ShaderPosition): void;
7
- dispose(): void;
8
- }
@@ -1,13 +0,0 @@
1
- import { IBaseSymbol } from "./IBaseSymbol";
2
- export declare class SymbolTable<T extends IBaseSymbol> {
3
- private _table;
4
- insert(symbol: T, isInMacroBranch?: boolean): void;
5
- getSymbol(symbol: T, includeMacro?: boolean): T | undefined;
6
- getSymbols(symbol: T, includeMacro: boolean | undefined, out: T[]): T[];
7
- /**
8
- * @internal
9
- */
10
- _getSymbols(symbol: T, includeMacro: boolean | undefined, out: T[]): T[];
11
- /** Iterate every registered symbol. Order within a name bucket is insertion order. */
12
- forEach(callback: (symbol: T) => void): void;
13
- }
@@ -1,17 +0,0 @@
1
- import { IBaseSymbol } from "./IBaseSymbol";
2
- import { SymbolTable } from "./SymbolTable";
3
- export declare class SymbolTableStack<S extends IBaseSymbol, T extends SymbolTable<S>> {
4
- stack: T[];
5
- /**
6
- * @internal
7
- */
8
- _macroLevel: number;
9
- get scope(): T;
10
- get isInMacroBranch(): boolean;
11
- pushScope(scope: T): void;
12
- clear(): void;
13
- popScope(): T | undefined;
14
- insert(symbol: S): void;
15
- lookup(symbol: S, includeMacro?: boolean): S | undefined;
16
- lookupAll(symbol: S, includeMacro: boolean | undefined, out: S[]): S[];
17
- }
@@ -1,124 +0,0 @@
1
- export declare enum Keyword {
2
- CONST = 0,
3
- BOOL = 1,
4
- FLOAT = 2,
5
- DOUBLE = 3,
6
- INT = 4,
7
- UINT = 5,
8
- BREAK = 6,
9
- CONTINUE = 7,
10
- DO = 8,
11
- ELSE = 9,
12
- FOR = 10,
13
- IF = 11,
14
- WHILE = 12,
15
- DISCARD = 13,
16
- RETURN = 14,
17
- BVEC2 = 15,
18
- BVEC3 = 16,
19
- BVEC4 = 17,
20
- IVEC2 = 18,
21
- IVEC3 = 19,
22
- IVEC4 = 20,
23
- UVEC2 = 21,
24
- UVEC3 = 22,
25
- UVEC4 = 23,
26
- VEC2 = 24,
27
- VEC3 = 25,
28
- VEC4 = 26,
29
- VEC4_ARRAY = 27,
30
- MAT2 = 28,
31
- MAT3 = 29,
32
- MAT4 = 30,
33
- MAT2X3 = 31,
34
- MAT2X4 = 32,
35
- MAT3X2 = 33,
36
- MAT3X4 = 34,
37
- MAT4X2 = 35,
38
- MAT4X3 = 36,
39
- IN = 37,
40
- OUT = 38,
41
- INOUT = 39,
42
- CENTROID = 40,
43
- SAMPLER2D = 41,
44
- SAMPLER3D = 42,
45
- SAMPLER_CUBE = 43,
46
- SAMPLER2D_SHADOW = 44,
47
- SAMPLER_CUBE_SHADOW = 45,
48
- SAMPLER2D_ARRAY = 46,
49
- SAMPLER2D_ARRAY_SHADOW = 47,
50
- I_SAMPLER2D = 48,
51
- I_SAMPLER3D = 49,
52
- I_SAMPLER_CUBE = 50,
53
- I_SAMPLER2D_ARRAY = 51,
54
- U_SAMPLER2D = 52,
55
- U_SAMPLER3D = 53,
56
- U_SAMPLER_CUBE = 54,
57
- U_SAMPLER2D_ARRAY = 55,
58
- STRUCT = 56,
59
- LAYOUT = 57,
60
- LOCATION = 58,
61
- VOID = 59,
62
- PRECISION = 60,
63
- PRECISE = 61,
64
- HIGHP = 62,
65
- MEDIUMP = 63,
66
- LOWP = 64,
67
- INVARIANT = 65,
68
- SMOOTH = 66,
69
- FLAT = 67,
70
- NOPERSPECTIVE = 68,
71
- True = 69,
72
- False = 70,
73
- LeftBrace = 71,
74
- RightBrace = 72,
75
- Equal = 73,
76
- BitwiseOr = 74,
77
- GSRenderQueueType = 75,
78
- GSBlendState = 76,
79
- GSDepthState = 77,
80
- GSStencilState = 78,
81
- GSRasterState = 79,
82
- GSEditorProperties = 80,
83
- GSEditorMacros = 81,
84
- GSEditor = 82,
85
- GSTags = 83,
86
- GSVertexShader = 84,
87
- GSFragmentShader = 85,
88
- GSSubShader = 86,
89
- GSPass = 87,
90
- GSBlendFactor = 88,
91
- GSBlendOperation = 89,
92
- GSBool = 90,
93
- GSNumber = 91,
94
- GSColor = 92,
95
- GSCompareFunction = 93,
96
- GSStencilOperation = 94,
97
- GSCullMode = 95,
98
- GSColorWriteMask = 96,
99
- GSUsePass = 97,
100
- MACRO_IF = 98,
101
- MACRO_IFDEF = 99,
102
- MACRO_IFNDEF = 100,
103
- MACRO_ELSE = 101,
104
- MACRO_ELIF = 102,
105
- MACRO_ENDIF = 103,
106
- MACRO_UNDEF = 104,
107
- /** Legacy opaque `#define` token — whole directive packed into one lexeme. Retained
108
- * for macros whose value can't be parsed as a GLSL expression (type aliases,
109
- * qualifier aliases, partial-syntax macros). Expression-style macros instead emit
110
- * `MACRO_DEFINE` + ID + value tokens + `MACRO_DEFINE_END`. */
111
- MACRO_DEFINE_EXPRESSION = 105,
112
- MACRO_CONDITIONAL_EXPRESSION = 106,
113
- MACRO_CALL = 107,
114
- /** `#define` directive head for expression-style macros. */
115
- MACRO_DEFINE = 108,
116
- /** Terminates a `MACRO_DEFINE` directive at end-of-line. */
117
- MACRO_DEFINE_END = 109,
118
- /** `(params)` block for a function-like `#define`. The lexer captures the entire
119
- * parenthesized parameter list as one opaque token so the macro-define CFG rule
120
- * doesn't need its own parameter-list production (which would conflict with
121
- * function_call_parameter_list under LALR(1)). The AST consumer parses the
122
- * lexeme to recover the individual parameter names. */
123
- MACRO_DEFINE_PARAMS = 110
124
- }
@@ -1,5 +0,0 @@
1
- export declare enum EShaderStage {
2
- VERTEX = 0,
3
- FRAGMENT = 1,
4
- ALL = 2
5
- }
@@ -1,5 +0,0 @@
1
- import { ShaderRange } from "./ShaderRange";
2
- import { ShaderPosition } from "./ShaderPosition";
3
- export { ShaderRange, ShaderPosition };
4
- export * from "./types";
5
- export * from "./enums/Keyword";
@@ -1,101 +0,0 @@
1
- import { Keyword } from "./enums/Keyword";
2
- export declare enum ETokenType {
3
- ID = 1000,
4
- FLOAT_CONSTANT = 1001,
5
- INT_CONSTANT = 1002,
6
- STRING_CONST = 1003,
7
- /** << */
8
- LEFT_OP = 1004,
9
- /** \>> */
10
- RIGHT_OP = 1005,
11
- /** ++ */
12
- INC_OP = 1006,
13
- /** -- */
14
- DEC_OP = 1007,
15
- /** <= */
16
- LE_OP = 1008,
17
- /** \>= */
18
- GE_OP = 1009,
19
- /** == */
20
- EQ_OP = 1010,
21
- /** != */
22
- NE_OP = 1011,
23
- /** && */
24
- AND_OP = 1012,
25
- /** || */
26
- OR_OP = 1013,
27
- /** ^^ */
28
- XOR_OP = 1014,
29
- /** *= */
30
- MUL_ASSIGN = 1015,
31
- /** /= */
32
- DIV_ASSIGN = 1016,
33
- /** += */
34
- ADD_ASSIGN = 1017,
35
- /** -= */
36
- SUB_ASSIGN = 1018,
37
- /** %= */
38
- MOD_ASSIGN = 1019,
39
- /** <<= */
40
- LEFT_ASSIGN = 1020,
41
- /** >>= */
42
- RIGHT_ASSIGN = 1021,
43
- /** &= */
44
- AND_ASSIGN = 1022,
45
- /** ^= */
46
- XOR_ASSIGN = 1023,
47
- /** |= */
48
- OR_ASSIGN = 1024,
49
- /** ( */
50
- LEFT_PAREN = 1025,
51
- /** ) */
52
- RIGHT_PAREN = 1026,
53
- /** [ */
54
- LEFT_BRACKET = 1027,
55
- /** ] */
56
- RIGHT_BRACKET = 1028,
57
- /** { */
58
- LEFT_BRACE = 1029,
59
- /** } */
60
- RIGHT_BRACE = 1030,
61
- /** . */
62
- DOT = 1031,
63
- /** , */
64
- COMMA = 1032,
65
- COLON = 1033,
66
- /** = */
67
- EQUAL = 1034,
68
- /** ; */
69
- SEMICOLON = 1035,
70
- /** ! */
71
- BANG = 1036,
72
- /** \- */
73
- DASH = 1037,
74
- /** ~ */
75
- TILDE = 1038,
76
- PLUS = 1039,
77
- /** \* */
78
- STAR = 1040,
79
- /** / */
80
- SLASH = 1041,
81
- /** % */
82
- PERCENT = 1042,
83
- /** < */
84
- LEFT_ANGLE = 1043,
85
- /** \> */
86
- RIGHT_ANGLE = 1044,
87
- VERTICAL_BAR = 1045,
88
- /** ^ */
89
- CARET = 1046,
90
- /** & */
91
- AMPERSAND = 1047,
92
- /** ? */
93
- QUESTION = 1048,
94
- NotWord = 1049,
95
- /** ε */
96
- EPSILON = 1998,
97
- EOF = 1999
98
- }
99
- export declare const TypeAny = 3000;
100
- export type GalaceanDataType = Keyword.VOID | Keyword.FLOAT | Keyword.BOOL | Keyword.INT | Keyword.UINT | Keyword.VEC2 | Keyword.VEC3 | Keyword.VEC4 | Keyword.BVEC2 | Keyword.BVEC3 | Keyword.BVEC4 | Keyword.IVEC2 | Keyword.IVEC3 | Keyword.IVEC4 | Keyword.UVEC2 | Keyword.UVEC3 | Keyword.UVEC4 | Keyword.MAT2 | Keyword.MAT3 | Keyword.MAT4 | Keyword.MAT2X3 | Keyword.MAT2X4 | Keyword.MAT3X2 | Keyword.MAT3X4 | Keyword.MAT4X2 | Keyword.MAT4X3 | Keyword.SAMPLER2D | Keyword.SAMPLER3D | Keyword.SAMPLER_CUBE | Keyword.SAMPLER2D_SHADOW | Keyword.SAMPLER_CUBE_SHADOW | Keyword.SAMPLER2D_ARRAY | Keyword.SAMPLER2D_ARRAY_SHADOW | Keyword.I_SAMPLER2D | Keyword.I_SAMPLER3D | Keyword.I_SAMPLER_CUBE | Keyword.I_SAMPLER2D_ARRAY | Keyword.U_SAMPLER2D | Keyword.U_SAMPLER3D | Keyword.U_SAMPLER_CUBE | Keyword.U_SAMPLER2D_ARRAY | Keyword.VEC4_ARRAY | typeof TypeAny | string;
101
- export type TokenType = ETokenType | Keyword;
@@ -1,5 +0,0 @@
1
- import { Grammar } from "../parser/Grammar";
2
- import SemanticAnalyzer from "../parser/SemanticAnalyzer";
3
- declare const createGrammar: () => Grammar;
4
- declare const addTranslationRule: (sa: SemanticAnalyzer) => void;
5
- export { addTranslationRule, createGrammar };
@@ -1,27 +0,0 @@
1
- import { Grammar } from "../parser/Grammar";
2
- import { NoneTerminal, Terminal } from "../parser/GrammarSymbol";
3
- import { StateActionTable, StateGotoTable } from "./types";
4
- /**
5
- * The [LALR1](https://web.stanford.edu/class/archive/cs/cs143/cs143.1128/handouts/140%20LALR%20Parsing.pdf) Parser generator
6
- */
7
- export declare class LALR1 {
8
- readonly firstSetMap: Map<NoneTerminal, Set<Terminal>>;
9
- readonly followSetMap: Map<NoneTerminal, Set<Terminal>>;
10
- readonly actionTable: StateActionTable;
11
- readonly gotoTable: StateGotoTable;
12
- private grammar;
13
- /** For circle detect */
14
- private _firstSetNTStack;
15
- constructor(grammar: Grammar);
16
- generate(): void;
17
- private buildStateTable;
18
- private _extendState;
19
- private _closure;
20
- private _extendStateItem;
21
- private _inferNextState;
22
- /** Resolve shift-reduce/reduce-reduce conflict detect */
23
- private _addAction;
24
- private static _isKnownShiftPreferred;
25
- private computeFirstSet;
26
- private _computeFirstSetForNT;
27
- }
@@ -1,9 +0,0 @@
1
- import { NoneTerminal, GrammarSymbol } from "../parser/GrammarSymbol";
2
- export default class Production {
3
- private static _id;
4
- static pool: Map<number, Production>;
5
- readonly goal: NoneTerminal;
6
- readonly derivation: GrammarSymbol[];
7
- readonly id: number;
8
- constructor(goal: NoneTerminal, derivation: GrammarSymbol[]);
9
- }
@@ -1,20 +0,0 @@
1
- import { Terminal } from "../parser/GrammarSymbol";
2
- import Production from "./Production";
3
- import StateItem from "./StateItem";
4
- export default class State {
5
- static closureMap: Map<string /** state mapKey */, State>;
6
- static pool: Map<number, State>;
7
- static _id: number;
8
- readonly id: number;
9
- readonly cores: Set<StateItem>;
10
- private _items;
11
- get items(): Set<StateItem>;
12
- closured: boolean;
13
- get needReInfer(): boolean;
14
- private _stateItemPool;
15
- static create(cores: StateItem[]): State;
16
- static getMapKey(cores: StateItem[]): string;
17
- private constructor();
18
- getStateItemMapKey(production: Production, position: number): string;
19
- createStateItem(production: Production, position: number, lookaheadSet?: Iterable<Terminal>): StateItem;
20
- }
@@ -1,20 +0,0 @@
1
- import { Terminal } from "../parser/GrammarSymbol";
2
- import Production from "./Production";
3
- export default class StateItem {
4
- static _id: number;
5
- readonly production: Production;
6
- readonly position: number;
7
- readonly lookaheadSet: Set<Terminal>;
8
- readonly id: number;
9
- _needReInfer: boolean;
10
- get needReInfer(): boolean;
11
- set needReInfer(v: boolean);
12
- get curSymbol(): import("../parser/GrammarSymbol").GrammarSymbol;
13
- get nextSymbol(): import("../parser/GrammarSymbol").GrammarSymbol;
14
- constructor(production: Production, position: number, lookahead: Iterable<Terminal>);
15
- addLookahead(ts: Iterable<Terminal>): void;
16
- symbolByOffset(offset: number): import("../parser/GrammarSymbol").GrammarSymbol;
17
- canReduce(): boolean;
18
- advance(): StateItem;
19
- toString(): string;
20
- }
@@ -1,22 +0,0 @@
1
- import { ShaderRange } from "../common";
2
- import { TreeNode } from "../parser/AST";
3
- import { TranslationRule } from "../parser/SemanticAnalyzer";
4
- import { NoneTerminal, GrammarSymbol } from "../parser/GrammarSymbol";
5
- import Production from "./Production";
6
- import { ActionInfo } from "./types";
7
- import { ClearableObjectPool, type IPoolElement } from "@galacean/engine-core";
8
- import { NodeChild } from "../parser/types";
9
- export default class GrammarUtils {
10
- static isTerminal(sm: GrammarSymbol): boolean;
11
- static toString(sm: GrammarSymbol): string;
12
- static createProductionWithOptions(goal: NoneTerminal, options: GrammarSymbol[][],
13
- /** the ast node */
14
- astTypePool?: ClearableObjectPool<{
15
- set: (loc: ShaderRange, children: NodeChild[]) => void;
16
- } & IPoolElement & TreeNode>): [GrammarSymbol[], TranslationRule | undefined][];
17
- static addMapSetItem<K, T>(map: Map<K, Set<T>>, k: K, v: T): void;
18
- static isSubSet<T>(sa: Set<T>, sb: Set<T>): boolean;
19
- static isActionEqual(a: ActionInfo, b: ActionInfo): boolean;
20
- static printAction(actionInfo: ActionInfo): string;
21
- static printProduction(production: Production): string;
22
- }
@@ -1,2 +0,0 @@
1
- export { LALR1 } from "./LALR1";
2
- export * from "./CFG";
@@ -1,14 +0,0 @@
1
- import { NoneTerminal, Terminal } from "../parser/GrammarSymbol";
2
- export type StateActionTable = Map<number /** state ID */, ActionTable>;
3
- export type ActionTable = Map<Terminal, ActionInfo>;
4
- export type StateGotoTable = Map<number /** state ID */, GotoTable>;
5
- export type GotoTable = Map<NoneTerminal, number /** state ID */>;
6
- export declare enum EAction {
7
- Shift = 0,
8
- Reduce = 1,
9
- Accept = 2
10
- }
11
- export interface ActionInfo {
12
- action: EAction;
13
- target?: number;
14
- }