@galacean/engine-shaderlab 1.6.8 → 1.6.10

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 (81) hide show
  1. package/dist/browser.js +8075 -0
  2. package/dist/browser.js.map +1 -0
  3. package/dist/browser.min.js +2 -0
  4. package/dist/browser.min.js.map +1 -0
  5. package/dist/browser.verbose.js +8864 -0
  6. package/dist/browser.verbose.js.map +1 -0
  7. package/dist/browser.verbose.min.js +2 -0
  8. package/dist/browser.verbose.min.js.map +1 -0
  9. package/dist/main.js +8071 -0
  10. package/dist/main.js.map +1 -0
  11. package/dist/main.verbose.js +8860 -0
  12. package/dist/main.verbose.js.map +1 -0
  13. package/dist/module.js +8064 -0
  14. package/dist/module.js.map +1 -0
  15. package/dist/module.verbose.js +8853 -0
  16. package/dist/module.verbose.js.map +1 -0
  17. package/package.json +4 -4
  18. package/types/GSError.d.ts +16 -0
  19. package/types/ParserUtils.d.ts +12 -0
  20. package/types/Preprocessor.d.ts +31 -0
  21. package/types/ShaderLab.d.ts +15 -0
  22. package/types/ShaderLabUtils.d.ts +10 -0
  23. package/types/TempArray.d.ts +5 -0
  24. package/types/codeGen/CodeGenVisitor.d.ts +1 -0
  25. package/types/codeGen/GLES100.d.ts +12 -0
  26. package/types/codeGen/GLES300.d.ts +20 -0
  27. package/types/codeGen/GLESVisitor.d.ts +1 -0
  28. package/types/codeGen/VisitorContext.d.ts +1 -0
  29. package/types/codeGen/index.d.ts +3 -0
  30. package/types/codeGen/types.d.ts +12 -0
  31. package/types/common/BaseLexer.d.ts +2 -0
  32. package/types/common/BaseToken.d.ts +12 -0
  33. package/types/common/IBaseSymbol.d.ts +5 -0
  34. package/types/common/ShaderPosition.d.ts +8 -0
  35. package/types/common/ShaderRange.d.ts +8 -0
  36. package/types/common/SymbolTable.d.ts +7 -0
  37. package/types/common/SymbolTableStack.d.ts +13 -0
  38. package/types/common/enums/Keyword.d.ts +108 -0
  39. package/types/common/enums/ShaderStage.d.ts +5 -0
  40. package/types/common/index.d.ts +5 -0
  41. package/types/common/types.d.ts +101 -0
  42. package/types/index.d.ts +3 -0
  43. package/types/lalr/CFG.d.ts +5 -0
  44. package/types/lalr/LALR1.d.ts +26 -0
  45. package/types/lalr/Production.d.ts +9 -0
  46. package/types/lalr/State.d.ts +20 -0
  47. package/types/lalr/StateItem.d.ts +20 -0
  48. package/types/lalr/Utils.d.ts +22 -0
  49. package/types/lalr/index.d.ts +2 -0
  50. package/types/lalr/types.d.ts +14 -0
  51. package/types/lexer/Lexer.d.ts +23 -0
  52. package/types/lexer/index.d.ts +1 -0
  53. package/types/macroProcessor/MacroDefine.d.ts +13 -0
  54. package/types/macroProcessor/MacroParser.d.ts +7 -0
  55. package/types/macroProcessor/MacroParserLexer.d.ts +32 -0
  56. package/types/macroProcessor/Utils.d.ts +5 -0
  57. package/types/macroProcessor/constants.d.ts +54 -0
  58. package/types/macroProcessor/index.d.ts +1 -0
  59. package/types/macroProcessor/sourceMap/index.d.ts +37 -0
  60. package/types/parser/AST.d.ts +448 -0
  61. package/types/parser/Grammar.d.ts +11 -0
  62. package/types/parser/GrammarSymbol.d.ts +127 -0
  63. package/types/parser/SemanticAnalyzer.d.ts +2 -0
  64. package/types/parser/ShaderInfo.d.ts +10 -0
  65. package/types/parser/ShaderTargetParser.d.ts +24 -0
  66. package/types/parser/builtin/functions.d.ts +35 -0
  67. package/types/parser/builtin/index.d.ts +2 -0
  68. package/types/parser/builtin/variables.d.ts +11 -0
  69. package/types/parser/index.d.ts +2 -0
  70. package/types/parser/symbolTable/FnSymbol.d.ts +6 -0
  71. package/types/parser/symbolTable/StructSymbol.d.ts +6 -0
  72. package/types/parser/symbolTable/SymbolDataType.d.ts +8 -0
  73. package/types/parser/symbolTable/SymbolInfo.d.ts +22 -0
  74. package/types/parser/symbolTable/VarSymbol.d.ts +8 -0
  75. package/types/parser/symbolTable/index.d.ts +6 -0
  76. package/types/parser/types.d.ts +24 -0
  77. package/types/sourceParser/ShaderSourceFactory.d.ts +8 -0
  78. package/types/sourceParser/ShaderSourceParser.d.ts +1 -0
  79. package/types/sourceParser/ShaderSourceSymbol.d.ts +10 -0
  80. package/types/sourceParser/SourceLexer.d.ts +19 -0
  81. package/types/sourceParser/index.d.ts +1 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@galacean/engine-shaderlab",
3
- "version": "1.6.8",
3
+ "version": "1.6.10",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -26,11 +26,11 @@
26
26
  "verbose/package.json"
27
27
  ],
28
28
  "devDependencies": {
29
- "@galacean/engine-design": "1.6.8",
30
- "@galacean/engine": "npm:@galacean/engine-backup@1.6.8"
29
+ "@galacean/engine-design": "1.6.10",
30
+ "@galacean/engine": "1.6.10"
31
31
  },
32
32
  "peerDependencies": {
33
- "@galacean/engine": "npm:@galacean/engine-backup@1.6.8"
33
+ "@galacean/engine": "1.6.10"
34
34
  },
35
35
  "scripts": {
36
36
  "b:types": "tsc"
@@ -0,0 +1,16 @@
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;
7
+ static wrappingLineCount: number;
8
+ constructor(name: GSErrorName, message: string, location: ShaderRange | ShaderPosition, source: string, file?: string);
9
+ toString(): string;
10
+ }
11
+ export declare enum GSErrorName {
12
+ PreprocessorError = "PreprocessorError",
13
+ CompilationError = "CompilationError",
14
+ ScannerError = "ScannerError",
15
+ CompilationWarn = "CompilationWarning"
16
+ }
@@ -0,0 +1,12 @@
1
+ import { GalaceanDataType } from "./common";
2
+ import { 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
+ * Check if type `tb` is compatible with type `ta`.
8
+ */
9
+ static typeCompatible(ta: GalaceanDataType, tb: GalaceanDataType | undefined): boolean;
10
+ static toString(sm: GrammarSymbol): string;
11
+ static isTerminal(sm: GrammarSymbol): boolean;
12
+ }
@@ -0,0 +1,31 @@
1
+ export declare enum MacroValueType {
2
+ Number = 0,// 1, 1.1
3
+ Symbol = 1,// variable name
4
+ FunctionCall = 2,// function call, e.g. clamp(a, 0.0, 1.0)
5
+ Other = 3
6
+ }
7
+ export interface MacroDefineInfo {
8
+ isFunction: boolean;
9
+ name: string;
10
+ value: string;
11
+ valueType: MacroValueType;
12
+ params: string[];
13
+ functionCallName: string;
14
+ }
15
+ export interface MacroDefineList {
16
+ [macroName: string]: MacroDefineInfo[];
17
+ }
18
+ export declare class Preprocessor {
19
+ private static readonly _includeReg;
20
+ private static readonly _macroRegex;
21
+ private static readonly _symbolReg;
22
+ private static readonly _funcCallReg;
23
+ private static readonly _macroDefineIncludeMap;
24
+ static parse(source: string, basePathForIncludeKey: string, outMacroDefineList: MacroDefineList, parseMacro?: boolean): string;
25
+ static getReferenceSymbolNames(macroDefineList: MacroDefineList, macroName: string, out: string[]): void;
26
+ private static _isNumber;
27
+ private static _isExist;
28
+ private static _parseMacroDefines;
29
+ private static _mergeMacroDefineLists;
30
+ private static _replace;
31
+ }
@@ -0,0 +1,15 @@
1
+ import { ShaderMacro, ShaderLanguage } from "@galacean/engine";
2
+ import { IShaderLab, IShaderSource } from "@galacean/engine-design";
3
+ import { IShaderProgramSource } from "@galacean/engine-design/types/shader-lab/IShaderProgramSource";
4
+ import { ShaderPosition, ShaderRange } from "./common";
5
+ export declare class ShaderLab implements IShaderLab {
6
+ private static _parser;
7
+ private static _shaderPositionPool;
8
+ private static _shaderRangePool;
9
+ static _processingPassText?: string;
10
+ static createPosition(index: number, line?: number, column?: number): ShaderPosition;
11
+ static createRange(start: ShaderPosition, end: ShaderPosition): ShaderRange;
12
+ _parseShaderSource(sourceCode: string): IShaderSource;
13
+ _parseShaderPass(source: string, vertexEntry: string, fragmentEntry: string, backend: ShaderLanguage, basePathForIncludeKey: string): IShaderProgramSource | undefined;
14
+ _parseMacros(content: string, macros: ShaderMacro[]): string;
15
+ }
@@ -0,0 +1,10 @@
1
+ import { ClearableObjectPool, IPoolElement } from "@galacean/engine";
2
+ import { GSErrorName } from "./GSError";
3
+ import { ShaderRange } from "./common/ShaderRange";
4
+ import { ShaderPosition } from "./common/ShaderPosition";
5
+ export declare class ShaderLabUtils {
6
+ private static _shaderLabObjectPoolSet;
7
+ static createObjectPool<T extends IPoolElement>(type: new () => T): ClearableObjectPool<T>;
8
+ static clearAllShaderLabObjectPool(): void;
9
+ static createGSError(message: string, errorName: GSErrorName, source: string, location: ShaderRange | ShaderPosition, file?: string): Error | undefined;
10
+ }
@@ -0,0 +1,5 @@
1
+ import { IPoolElement } from "@galacean/engine";
2
+ export declare class TempArray<T> implements IPoolElement {
3
+ array: Array<T>;
4
+ dispose(): void;
5
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,12 @@
1
+ import { ASTNode } from "../parser/AST";
2
+ import { StructProp } from "../parser/types";
3
+ import { GLESVisitor } from "./GLESVisitor";
4
+ export declare class GLES100Visitor extends GLESVisitor {
5
+ private static _singleton;
6
+ static getVisitor(): GLES100Visitor;
7
+ getAttributeProp(prop: StructProp): string;
8
+ getVaryingProp(prop: StructProp): string;
9
+ getMRTProp(): string;
10
+ visitPostfixExpression(node: ASTNode.PostfixExpression): string;
11
+ visitJumpStatement(node: ASTNode.JumpStatement): string;
12
+ }
@@ -0,0 +1,20 @@
1
+ import { ASTNode } from "../parser/AST";
2
+ import { ShaderData } from "../parser/ShaderInfo";
3
+ import { StructProp } from "../parser/types";
4
+ import { GLESVisitor } from "./GLESVisitor";
5
+ import { ICodeSegment } from "./types";
6
+ export declare class GLES300Visitor extends GLESVisitor {
7
+ private static _singleton;
8
+ static getVisitor(): GLES300Visitor;
9
+ private _otherCodeArray;
10
+ private _fragColorVariableRegistered;
11
+ reset(): void;
12
+ getOtherGlobal(data: ShaderData, out: ICodeSegment[]): void;
13
+ getAttributeProp(prop: StructProp): string;
14
+ getVaryingProp(prop: StructProp): string;
15
+ getMRTProp(prop: StructProp): string;
16
+ visitFunctionIdentifier(node: ASTNode.FunctionIdentifier): string;
17
+ visitVariableIdentifier(node: ASTNode.VariableIdentifier): string;
18
+ visitJumpStatement(node: ASTNode.JumpStatement): string;
19
+ private _registerFragColorVariable;
20
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ export { GLES100Visitor } from "./GLES100";
2
+ export { GLES300Visitor } from "./GLES300";
3
+ export { CodeGenVisitor } from "./CodeGenVisitor";
@@ -0,0 +1,12 @@
1
+ import { IShaderSource } from "@galacean/engine-design";
2
+ export type IRenderState = [
3
+ /** Constant RenderState. */
4
+ Record<number, boolean | string | number | any>,
5
+ /** Variable RenderState. */
6
+ Record<number, string>
7
+ ];
8
+ export type ITag = IShaderSource["subShaders"][number]["tags"];
9
+ export type ICodeSegment = {
10
+ text: string;
11
+ index: number;
12
+ };
@@ -0,0 +1,2 @@
1
+ import { BaseToken } from "./BaseToken";
2
+ export type OnToken = (token: BaseToken, scanner: BaseLexer) => void;
@@ -0,0 +1,12 @@
1
+ import { ShaderRange, ShaderPosition } from ".";
2
+ import { IPoolElement } from "@galacean/engine";
3
+ export declare class BaseToken<T extends number = number> implements IPoolElement {
4
+ static pool: import("@galacean/engine").ClearableObjectPool<BaseToken<number>>;
5
+ type: T;
6
+ lexeme: string;
7
+ location: ShaderRange;
8
+ set(type: T, lexeme: string, start?: ShaderPosition): any;
9
+ set(type: T, lexeme: string, location?: ShaderRange): any;
10
+ dispose(): void;
11
+ }
12
+ export declare const EOF: BaseToken<number>;
@@ -0,0 +1,5 @@
1
+ export interface IBaseSymbol {
2
+ isInMacroBranch: boolean;
3
+ readonly ident: string;
4
+ equal(other: IBaseSymbol): boolean;
5
+ }
@@ -0,0 +1,8 @@
1
+ import { IPoolElement } from "@galacean/engine";
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
+ }
@@ -0,0 +1,8 @@
1
+ import { IPoolElement } from "@galacean/engine";
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
+ }
@@ -0,0 +1,7 @@
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, out: T[]): T[];
7
+ }
@@ -0,0 +1,13 @@
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
+ get scope(): T;
6
+ get isInMacroBranch(): boolean;
7
+ pushScope(scope: T): void;
8
+ clear(): void;
9
+ popScope(): T | undefined;
10
+ insert(symbol: S): void;
11
+ lookup(symbol: S, includeMacro?: boolean): S | undefined;
12
+ lookupAll(symbol: S, includeMacro: boolean, out: S[]): S[];
13
+ }
@@ -0,0 +1,108 @@
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
+ GSRenderQueueType = 74,
77
+ GSBlendState = 75,
78
+ GSDepthState = 76,
79
+ GSStencilState = 77,
80
+ GSRasterState = 78,
81
+ GSEditorProperties = 79,
82
+ GSEditorMacros = 80,
83
+ GSEditor = 81,
84
+ GSTags = 82,
85
+ GSVertexShader = 83,
86
+ GSFragmentShader = 84,
87
+ GSSubShader = 85,
88
+ GSPass = 86,
89
+ GSBlendFactor = 87,
90
+ GSBlendOperation = 88,
91
+ GSBool = 89,
92
+ GSNumber = 90,
93
+ GSColor = 91,
94
+ GSCompareFunction = 92,
95
+ GSStencilOperation = 93,
96
+ GSCullMode = 94,
97
+ GSUsePass = 95,
98
+ MACRO_IF = 96,
99
+ MACRO_IFDEF = 97,
100
+ MACRO_IFNDEF = 98,
101
+ MACRO_ELSE = 99,
102
+ MACRO_ELIF = 100,
103
+ MACRO_ENDIF = 101,
104
+ MACRO_UNDEF = 102,
105
+ MACRO_DEFINE_EXPRESSION = 103,
106
+ MACRO_CONDITIONAL_EXPRESSION = 104,
107
+ MACRO_CALL = 105
108
+ }
@@ -0,0 +1,5 @@
1
+ export declare enum EShaderStage {
2
+ VERTEX = 0,
3
+ FRAGMENT = 1,
4
+ ALL = 2
5
+ }
@@ -0,0 +1,5 @@
1
+ import { ShaderRange } from "./ShaderRange";
2
+ import { ShaderPosition } from "./ShaderPosition";
3
+ export { ShaderRange, ShaderPosition };
4
+ export * from "./types";
5
+ export * from "./enums/Keyword";
@@ -0,0 +1,101 @@
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;
@@ -0,0 +1,3 @@
1
+ export { ShaderLab } from "./ShaderLab";
2
+ export * from "./GSError";
3
+ export declare const version = "__buildVersion";
@@ -0,0 +1,5 @@
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 };
@@ -0,0 +1,26 @@
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 computeFirstSet;
25
+ private _computeFirstSetForNT;
26
+ }
@@ -0,0 +1,9 @@
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
+ }
@@ -0,0 +1,20 @@
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
+ }
@@ -0,0 +1,20 @@
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
+ }
@@ -0,0 +1,22 @@
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, IPoolElement } from "@galacean/engine";
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][];
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
+ }
@@ -0,0 +1,2 @@
1
+ export { LALR1 } from "./LALR1";
2
+ export * from "./CFG";
@@ -0,0 +1,14 @@
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
+ }
@@ -0,0 +1,23 @@
1
+ import { BaseLexer } from "../common/BaseLexer";
2
+ import { BaseToken } from "../common/BaseToken";
3
+ import { MacroDefineList } from "../Preprocessor";
4
+ /**
5
+ * The Lexer of ShaderLab Compiler
6
+ */
7
+ export declare class Lexer extends BaseLexer {
8
+ macroDefineList: MacroDefineList;
9
+ private static _lexemeTable;
10
+ private _needScanMacroConditionExpression;
11
+ tokenize(): Generator<BaseToken<number>, BaseToken<number>, unknown>;
12
+ constructor(source: string, macroDefineList: MacroDefineList);
13
+ scanToken(): BaseToken;
14
+ private _scanStringConst;
15
+ private _scanNumAfterDot;
16
+ private _scanUtilBreakLine;
17
+ private _scanDirectives;
18
+ private _scanMacroConditionExpression;
19
+ private _scanWord;
20
+ private _scanNum;
21
+ private _scanFloatSuffix;
22
+ private _scanIntegerSuffix;
23
+ }
@@ -0,0 +1 @@
1
+ export * from "./Lexer";
@@ -0,0 +1,13 @@
1
+ import { ShaderRange } from "../common";
2
+ import { BaseToken } from "../common/BaseToken";
3
+ export declare class MacroDefine {
4
+ readonly macro: BaseToken;
5
+ readonly body?: BaseToken;
6
+ readonly location?: ShaderRange;
7
+ readonly args?: BaseToken[];
8
+ private _replaceRegex?;
9
+ private readonly _argsLexemes?;
10
+ get isFunction(): boolean;
11
+ constructor(macro: BaseToken, body?: BaseToken, location?: ShaderRange, args?: BaseToken[]);
12
+ expandFunctionBody(args: string[]): string;
13
+ }