@galacean/engine-shaderlab 1.6.0-alpha.2 → 1.6.0-beta.1
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.
- package/dist/browser.js +6325 -4885
- package/dist/browser.js.map +1 -1
- package/dist/browser.min.js +1 -1
- package/dist/browser.min.js.map +1 -1
- package/dist/browser.verbose.js +5956 -4985
- package/dist/browser.verbose.js.map +1 -1
- package/dist/browser.verbose.min.js +1 -1
- package/dist/browser.verbose.min.js.map +1 -1
- package/dist/main.js +6325 -4885
- package/dist/main.js.map +1 -1
- package/dist/main.verbose.js +5956 -4985
- package/dist/main.verbose.js.map +1 -1
- package/dist/module.js +6325 -4887
- package/dist/module.js.map +1 -1
- package/dist/module.verbose.js +5958 -4986
- package/dist/module.verbose.js.map +1 -1
- package/package.json +4 -4
- package/types/GSError.d.ts +2 -1
- package/types/ParserUtils.d.ts +1 -1
- package/types/Preprocessor.d.ts +31 -0
- package/types/ShaderLab.d.ts +15 -1
- package/types/codeGen/CodeGenVisitor.d.ts +1 -2
- package/types/codeGen/GLES100.d.ts +4 -8
- package/types/codeGen/GLES300.d.ts +9 -6
- package/types/codeGen/types.d.ts +2 -2
- package/types/common/BaseLexer.d.ts +2 -0
- package/types/common/IBaseSymbol.d.ts +5 -0
- package/types/common/SymbolTable.d.ts +7 -0
- package/types/common/SymbolTableStack.d.ts +13 -0
- package/types/common/enums/Keyword.d.ts +108 -0
- package/types/common/index.d.ts +1 -1
- package/types/common/types.d.ts +4 -5
- package/types/index.d.ts +0 -1
- package/types/lalr/CFG.d.ts +1 -1
- package/types/lexer/Lexer.d.ts +10 -5
- package/types/{preprocessor → macroProcessor}/MacroDefine.d.ts +2 -2
- package/types/macroProcessor/MacroParserLexer.d.ts +32 -0
- package/types/macroProcessor/Utils.d.ts +5 -0
- package/types/{preprocessor → macroProcessor}/constants.d.ts +4 -6
- package/types/macroProcessor/index.d.ts +1 -0
- package/types/parser/AST.d.ts +124 -23
- package/types/parser/GrammarSymbol.d.ts +21 -1
- package/types/parser/ShaderInfo.d.ts +4 -2
- package/types/parser/ShaderTargetParser.d.ts +3 -2
- package/types/parser/builtin/functions.d.ts +2 -1
- package/types/parser/builtin/variables.d.ts +1 -1
- package/types/parser/symbolTable/SymbolInfo.d.ts +12 -8
- package/types/parser/symbolTable/index.d.ts +1 -1
- package/types/parser/types.d.ts +7 -6
- package/types/sourceParser/ShaderSourceFactory.d.ts +8 -0
- package/types/sourceParser/ShaderSourceSymbol.d.ts +10 -0
- package/types/sourceParser/SourceLexer.d.ts +19 -0
- package/types/sourceParser/index.d.ts +1 -0
- package/types/common/BaseScanner.d.ts +0 -2
- package/types/common/BaseSymbolTable.d.ts +0 -18
- package/types/common/Keywords.d.ts +0 -99
- package/types/contentParser/ContentSymbolTable.d.ts +0 -10
- package/types/contentParser/KeywordMap.d.ts +0 -2
- package/types/contentParser/Scanner.d.ts +0 -10
- package/types/contentParser/index.d.ts +0 -1
- package/types/lexer/Utils.d.ts +0 -7
- package/types/parser/symbolTable/TargetSymbolTable.d.ts +0 -13
- package/types/preprocessor/PpScanner.d.ts +0 -51
- package/types/preprocessor/Preprocessor.d.ts +0 -1
- package/types/preprocessor/Utils.d.ts +0 -10
- package/types/preprocessor/index.d.ts +0 -1
- /package/types/common/{Enums.d.ts → enums/ShaderStage.d.ts} +0 -0
- /package/types/{preprocessor/PpParser.d.ts → macroProcessor/MacroParser.d.ts} +0 -0
- /package/types/{preprocessor → macroProcessor}/sourceMap/index.d.ts +0 -0
- /package/types/{contentParser/ShaderContentParser.d.ts → sourceParser/ShaderSourceParser.d.ts} +0 -0
package/types/parser/AST.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { BuiltinVariable } from "./builtin";
|
|
2
1
|
import { ClearableObjectPool, IPoolElement } from "@galacean/engine";
|
|
3
2
|
import { CodeGenVisitor } from "../codeGen";
|
|
4
|
-
import {
|
|
5
|
-
import { BaseToken
|
|
3
|
+
import { GalaceanDataType, ShaderRange, TokenType } from "../common";
|
|
4
|
+
import { BaseToken } from "../common/BaseToken";
|
|
5
|
+
import { Keyword } from "../common/enums/Keyword";
|
|
6
6
|
import { NoneTerminal } from "./GrammarSymbol";
|
|
7
7
|
import SemanticAnalyzer from "./SemanticAnalyzer";
|
|
8
8
|
import { ShaderData } from "./ShaderInfo";
|
|
9
|
-
import { FnSymbol, StructSymbol
|
|
9
|
+
import { FnSymbol, StructSymbol } from "./symbolTable";
|
|
10
10
|
import { IParamInfo, NodeChild, StructProp, SymbolType } from "./types";
|
|
11
11
|
export declare abstract class TreeNode implements IPoolElement {
|
|
12
12
|
static pool: ClearableObjectPool<TreeNode & {
|
|
@@ -15,12 +15,24 @@ export declare abstract class TreeNode implements IPoolElement {
|
|
|
15
15
|
/** The non-terminal in grammar. */
|
|
16
16
|
nt: NoneTerminal;
|
|
17
17
|
private _children;
|
|
18
|
+
private _parent;
|
|
18
19
|
private _location;
|
|
20
|
+
private _codeCache;
|
|
21
|
+
/**
|
|
22
|
+
* Parent pointer for AST traversal.
|
|
23
|
+
* @remarks
|
|
24
|
+
* The parent pointer is only reliable after the entire AST has been constructed.
|
|
25
|
+
* DO NOT rely on `parent` during the `semanticAnalyze` phase, as the AST may still be under construction.
|
|
26
|
+
* It is safe to use `parent` during code generation or any phase after AST construction.
|
|
27
|
+
*/
|
|
28
|
+
get parent(): TreeNode;
|
|
19
29
|
get children(): NodeChild[];
|
|
20
30
|
get location(): ShaderRange;
|
|
21
31
|
set(loc: ShaderRange, children: NodeChild[]): void;
|
|
22
32
|
init(): void;
|
|
23
33
|
dispose(): void;
|
|
34
|
+
setCache(code: string): string;
|
|
35
|
+
getCache(): string;
|
|
24
36
|
codeGen(visitor: CodeGenVisitor): string;
|
|
25
37
|
/**
|
|
26
38
|
* Do semantic analyze right after the ast node is generated.
|
|
@@ -28,6 +40,7 @@ export declare abstract class TreeNode implements IPoolElement {
|
|
|
28
40
|
semanticAnalyze(sa: SemanticAnalyzer): void;
|
|
29
41
|
}
|
|
30
42
|
export declare namespace ASTNode {
|
|
43
|
+
type MacroExpression = MacroPushContext | MacroPopContext | MacroElseExpression | MacroElifExpression | MacroUndef | BaseToken;
|
|
31
44
|
export type ASTNodePool = ClearableObjectPool<{
|
|
32
45
|
set: (loc: ShaderRange, children: NodeChild[]) => void;
|
|
33
46
|
} & IPoolElement & TreeNode>;
|
|
@@ -88,12 +101,12 @@ export declare namespace ASTNode {
|
|
|
88
101
|
export class TypeQualifier extends TreeNode {
|
|
89
102
|
}
|
|
90
103
|
export class SingleTypeQualifier extends TreeNode {
|
|
91
|
-
qualifier:
|
|
104
|
+
qualifier: Keyword;
|
|
92
105
|
lexeme: string;
|
|
93
106
|
semanticAnalyze(sa: SemanticAnalyzer): void;
|
|
94
107
|
}
|
|
95
108
|
abstract class BasicTypeQualifier extends TreeNode {
|
|
96
|
-
qualifier:
|
|
109
|
+
qualifier: Keyword;
|
|
97
110
|
lexeme: string;
|
|
98
111
|
semanticAnalyze(sa: SemanticAnalyzer): void;
|
|
99
112
|
}
|
|
@@ -143,7 +156,7 @@ export declare namespace ASTNode {
|
|
|
143
156
|
semanticAnalyze(sa: SemanticAnalyzer): void;
|
|
144
157
|
}
|
|
145
158
|
export class IdentifierList extends TreeNode {
|
|
146
|
-
idList:
|
|
159
|
+
idList: BaseToken[];
|
|
147
160
|
init(): void;
|
|
148
161
|
semanticAnalyze(sa: SemanticAnalyzer): void;
|
|
149
162
|
}
|
|
@@ -151,22 +164,21 @@ export declare namespace ASTNode {
|
|
|
151
164
|
codeGen(visitor: CodeGenVisitor): string;
|
|
152
165
|
}
|
|
153
166
|
export class FunctionProtoType extends TreeNode {
|
|
154
|
-
ident:
|
|
167
|
+
ident: BaseToken;
|
|
155
168
|
returnType: FullySpecifiedType;
|
|
156
169
|
parameterList: IParamInfo[];
|
|
157
|
-
paramSig: GalaceanDataType[];
|
|
170
|
+
paramSig: GalaceanDataType[] | undefined;
|
|
158
171
|
semanticAnalyze(sa: SemanticAnalyzer): void;
|
|
159
|
-
codeGen(visitor: CodeGenVisitor): string;
|
|
160
172
|
}
|
|
161
173
|
export class FunctionDeclarator extends TreeNode {
|
|
162
|
-
ident:
|
|
174
|
+
ident: BaseToken;
|
|
163
175
|
returnType: FullySpecifiedType;
|
|
164
176
|
parameterInfoList: IParamInfo[] | undefined;
|
|
165
177
|
paramSig: GalaceanDataType[] | undefined;
|
|
166
178
|
semanticAnalyze(sa: SemanticAnalyzer): void;
|
|
167
179
|
}
|
|
168
180
|
export class FunctionHeader extends TreeNode {
|
|
169
|
-
ident:
|
|
181
|
+
ident: BaseToken;
|
|
170
182
|
returnType: FullySpecifiedType;
|
|
171
183
|
semanticAnalyze(sa: SemanticAnalyzer): void;
|
|
172
184
|
codeGen(visitor: CodeGenVisitor): string;
|
|
@@ -178,15 +190,20 @@ export declare namespace ASTNode {
|
|
|
178
190
|
semanticAnalyze(sa: SemanticAnalyzer): void;
|
|
179
191
|
codeGen(visitor: CodeGenVisitor): string;
|
|
180
192
|
}
|
|
193
|
+
export class MacroParamCaseList extends TreeNode {
|
|
194
|
+
}
|
|
195
|
+
export class MacroParamBlock extends TreeNode {
|
|
196
|
+
}
|
|
197
|
+
export class MacroParameterBranch extends TreeNode {
|
|
198
|
+
}
|
|
181
199
|
export class ParameterDeclaration extends TreeNode {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
ident: Token;
|
|
200
|
+
typeInfo?: SymbolType;
|
|
201
|
+
ident?: BaseToken;
|
|
185
202
|
init(): void;
|
|
186
203
|
semanticAnalyze(sa: SemanticAnalyzer): void;
|
|
187
204
|
}
|
|
188
205
|
export class ParameterDeclarator extends TreeNode {
|
|
189
|
-
ident:
|
|
206
|
+
ident: BaseToken;
|
|
190
207
|
typeInfo: SymbolType;
|
|
191
208
|
semanticAnalyze(sa: SemanticAnalyzer): void;
|
|
192
209
|
}
|
|
@@ -205,6 +222,7 @@ export declare namespace ASTNode {
|
|
|
205
222
|
returnStatement?: ASTNode.JumpStatement;
|
|
206
223
|
protoType: FunctionProtoType;
|
|
207
224
|
statements: CompoundStatementNoScope;
|
|
225
|
+
isInMacroBranch: boolean;
|
|
208
226
|
init(): void;
|
|
209
227
|
semanticAnalyze(sa: SemanticAnalyzer): void;
|
|
210
228
|
codeGen(visitor: CodeGenVisitor): string;
|
|
@@ -220,10 +238,16 @@ export declare namespace ASTNode {
|
|
|
220
238
|
}
|
|
221
239
|
export class FunctionCallParameterList extends TreeNode {
|
|
222
240
|
paramSig: GalaceanDataType[];
|
|
223
|
-
paramNodes: AssignmentExpression
|
|
241
|
+
paramNodes: Array<AssignmentExpression | MacroCallArgBlock>;
|
|
224
242
|
init(): void;
|
|
225
243
|
semanticAnalyze(sa: SemanticAnalyzer): void;
|
|
226
244
|
}
|
|
245
|
+
export class MacroCallArgCaseList extends TreeNode {
|
|
246
|
+
}
|
|
247
|
+
export class MacroCallArgBlock extends TreeNode {
|
|
248
|
+
}
|
|
249
|
+
export class MacroCallArgBranch extends TreeNode {
|
|
250
|
+
}
|
|
227
251
|
export class PrecisionSpecifier extends TreeNode {
|
|
228
252
|
semanticAnalyze(sa: SemanticAnalyzer): void;
|
|
229
253
|
}
|
|
@@ -291,23 +315,40 @@ export declare namespace ASTNode {
|
|
|
291
315
|
semanticAnalyze(sa: SemanticAnalyzer): void;
|
|
292
316
|
}
|
|
293
317
|
export class StructSpecifier extends TreeNode {
|
|
294
|
-
ident?:
|
|
318
|
+
ident?: BaseToken;
|
|
295
319
|
propList: StructProp[];
|
|
320
|
+
macroExpressions: MacroExpression[];
|
|
321
|
+
isInMacroBranch: boolean;
|
|
296
322
|
init(): void;
|
|
297
323
|
semanticAnalyze(sa: SemanticAnalyzer): void;
|
|
324
|
+
codeGen(visitor: CodeGenVisitor): string;
|
|
298
325
|
}
|
|
299
326
|
export class StructDeclarationList extends TreeNode {
|
|
300
327
|
propList: StructProp[];
|
|
328
|
+
macroExpressions: MacroExpression[];
|
|
301
329
|
init(): void;
|
|
302
330
|
semanticAnalyze(sa: SemanticAnalyzer): void;
|
|
303
331
|
}
|
|
304
332
|
export class StructDeclaration extends TreeNode {
|
|
305
|
-
typeSpecifier: TypeSpecifier;
|
|
306
|
-
declaratorList: StructDeclaratorList;
|
|
307
333
|
props: StructProp[];
|
|
334
|
+
macroExpressions: MacroExpression[];
|
|
335
|
+
private _typeSpecifier?;
|
|
336
|
+
private _declaratorList?;
|
|
308
337
|
init(): void;
|
|
309
338
|
semanticAnalyze(sa: SemanticAnalyzer): void;
|
|
310
339
|
}
|
|
340
|
+
export class MacroStructDeclaration extends TreeNode {
|
|
341
|
+
props: StructProp[];
|
|
342
|
+
macroExpressions: MacroExpression[];
|
|
343
|
+
init(): void;
|
|
344
|
+
semanticAnalyze(): void;
|
|
345
|
+
}
|
|
346
|
+
export class MacroStructBranch extends TreeNode {
|
|
347
|
+
props: StructProp[];
|
|
348
|
+
macroExpressions: MacroExpression[];
|
|
349
|
+
init(): void;
|
|
350
|
+
semanticAnalyze(): void;
|
|
351
|
+
}
|
|
311
352
|
export class LayoutQualifier extends TreeNode {
|
|
312
353
|
index: number;
|
|
313
354
|
semanticAnalyze(sa: SemanticAnalyzer): void;
|
|
@@ -318,30 +359,90 @@ export declare namespace ASTNode {
|
|
|
318
359
|
semanticAnalyze(sa: SemanticAnalyzer): void;
|
|
319
360
|
}
|
|
320
361
|
export class StructDeclarator extends TreeNode {
|
|
321
|
-
ident:
|
|
362
|
+
ident: BaseToken;
|
|
322
363
|
arraySpecifier: ArraySpecifier | undefined;
|
|
323
364
|
init(): void;
|
|
324
365
|
semanticAnalyze(sa: SemanticAnalyzer): void;
|
|
325
366
|
}
|
|
326
367
|
export class VariableDeclaration extends TreeNode {
|
|
327
368
|
type: FullySpecifiedType;
|
|
369
|
+
isStatic: boolean;
|
|
370
|
+
init(): void;
|
|
328
371
|
semanticAnalyze(sa: SemanticAnalyzer): void;
|
|
329
372
|
codeGen(visitor: CodeGenVisitor): string;
|
|
330
373
|
}
|
|
331
374
|
export class VariableDeclarationList extends TreeNode {
|
|
332
375
|
type: FullySpecifiedType;
|
|
376
|
+
variableDeclarations: VariableDeclaration[];
|
|
377
|
+
init(): void;
|
|
333
378
|
semanticAnalyze(sa: SemanticAnalyzer): void;
|
|
334
379
|
}
|
|
335
380
|
export class VariableIdentifier extends TreeNode {
|
|
336
|
-
symbolInfo: VarSymbol | BuiltinVariable | null;
|
|
337
|
-
lexeme: string;
|
|
338
381
|
typeInfo: GalaceanDataType;
|
|
382
|
+
referenceGlobalSymbolNames: string[];
|
|
383
|
+
private _symbols;
|
|
384
|
+
init(): void;
|
|
339
385
|
semanticAnalyze(sa: SemanticAnalyzer): void;
|
|
340
386
|
codeGen(visitor: CodeGenVisitor): string;
|
|
387
|
+
getLexeme(visitor: CodeGenVisitor): string;
|
|
341
388
|
}
|
|
342
389
|
export class GLShaderProgram extends TreeNode {
|
|
343
390
|
shaderData: ShaderData;
|
|
344
391
|
semanticAnalyze(sa: SemanticAnalyzer): void;
|
|
345
392
|
}
|
|
393
|
+
export class GlobalDeclaration extends TreeNode {
|
|
394
|
+
macroExpressions: Array<MacroExpression | MacroUndef | BaseToken>;
|
|
395
|
+
init(): void;
|
|
396
|
+
semanticAnalyze(sa: SemanticAnalyzer): void;
|
|
397
|
+
}
|
|
398
|
+
export class MacroUndef extends TreeNode {
|
|
399
|
+
codeGen(visitor: CodeGenVisitor): string;
|
|
400
|
+
}
|
|
401
|
+
export class MacroPushContext extends TreeNode {
|
|
402
|
+
semanticAnalyze(sa: SemanticAnalyzer): void;
|
|
403
|
+
codeGen(visitor: CodeGenVisitor): string;
|
|
404
|
+
}
|
|
405
|
+
export class MacroPopContext extends TreeNode {
|
|
406
|
+
semanticAnalyze(sa: SemanticAnalyzer): void;
|
|
407
|
+
codeGen(visitor: CodeGenVisitor): string;
|
|
408
|
+
}
|
|
409
|
+
export class MacroElifExpression extends TreeNode {
|
|
410
|
+
codeGen(visitor: CodeGenVisitor): string;
|
|
411
|
+
}
|
|
412
|
+
export class MacroElseExpression extends TreeNode {
|
|
413
|
+
codeGen(visitor: CodeGenVisitor): string;
|
|
414
|
+
}
|
|
415
|
+
export class GlobalMacroDeclaration extends TreeNode {
|
|
416
|
+
macroExpressions: MacroExpression[];
|
|
417
|
+
init(): void;
|
|
418
|
+
semanticAnalyze(sa: SemanticAnalyzer): void;
|
|
419
|
+
codeGen(visitor: CodeGenVisitor): string;
|
|
420
|
+
}
|
|
421
|
+
export class GlobalMacroIfStatement extends TreeNode {
|
|
422
|
+
macroExpressions: MacroExpression[];
|
|
423
|
+
init(): void;
|
|
424
|
+
semanticAnalyze(sa: SemanticAnalyzer): void;
|
|
425
|
+
}
|
|
426
|
+
export class GlobalMacroBranch extends TreeNode {
|
|
427
|
+
macroExpressions: MacroExpression[];
|
|
428
|
+
init(): void;
|
|
429
|
+
semanticAnalyze(sa: SemanticAnalyzer): void;
|
|
430
|
+
}
|
|
431
|
+
export class MacroIfStatement extends TreeNode {
|
|
432
|
+
}
|
|
433
|
+
export class MacroBranch extends TreeNode {
|
|
434
|
+
}
|
|
435
|
+
export class MacroCallSymbol extends TreeNode {
|
|
436
|
+
referenceSymbolNames: string[];
|
|
437
|
+
macroName: string;
|
|
438
|
+
init(): void;
|
|
439
|
+
semanticAnalyze(sa: SemanticAnalyzer): void;
|
|
440
|
+
}
|
|
441
|
+
export class MacroCallFunction extends TreeNode {
|
|
442
|
+
referenceSymbolNames: string[];
|
|
443
|
+
macroName: string;
|
|
444
|
+
semanticAnalyze(sa: SemanticAnalyzer): void;
|
|
445
|
+
codeGen(visitor: CodeGenVisitor): string;
|
|
446
|
+
}
|
|
346
447
|
export {};
|
|
347
448
|
}
|
|
@@ -101,7 +101,27 @@ export declare enum NoneTerminal {
|
|
|
101
101
|
typename_identifier_node = 2097,
|
|
102
102
|
scope_brace = 2098,
|
|
103
103
|
scope_end_brace = 2099,
|
|
104
|
-
|
|
104
|
+
macro_undef = 2100,
|
|
105
|
+
macro_push_context = 2101,
|
|
106
|
+
macro_pop_context = 2102,
|
|
107
|
+
macro_elif_expression = 2103,
|
|
108
|
+
macro_else_expression = 2104,
|
|
109
|
+
global_macro_if_statement = 2105,
|
|
110
|
+
global_macro_declaration = 2106,
|
|
111
|
+
global_macro_branch = 2107,
|
|
112
|
+
macro_struct_declaration = 2108,
|
|
113
|
+
macro_struct_branch = 2109,
|
|
114
|
+
macro_if_statement = 2110,
|
|
115
|
+
macro_branch = 2111,
|
|
116
|
+
macro_param_case_list = 2112,
|
|
117
|
+
macro_param_block = 2113,
|
|
118
|
+
macro_parameter_branch = 2114,
|
|
119
|
+
macro_call_arg_case_list = 2115,
|
|
120
|
+
macro_call_arg_block = 2116,
|
|
121
|
+
macro_call_arg_branch = 2117,
|
|
122
|
+
macro_call_symbol = 2118,
|
|
123
|
+
macro_call_function = 2119,
|
|
124
|
+
_ignore = 2120
|
|
105
125
|
}
|
|
106
126
|
export type GrammarSymbol = Terminal | NoneTerminal;
|
|
107
127
|
export type Derivation = GrammarSymbol[];
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { SymbolInfo, SymbolTable } from "../parser/symbolTable";
|
|
1
2
|
import { ASTNode } from "./AST";
|
|
2
|
-
import { TargetSymbolTable } from "../parser/symbolTable";
|
|
3
3
|
export declare class ShaderData {
|
|
4
|
-
symbolTable:
|
|
4
|
+
symbolTable: SymbolTable<SymbolInfo>;
|
|
5
5
|
vertexMain: ASTNode.FunctionDefinition;
|
|
6
6
|
fragmentMain: ASTNode.FunctionDefinition;
|
|
7
7
|
globalPrecisions: ASTNode.PrecisionSpecifier[];
|
|
8
|
+
globalMacroDeclarations: ASTNode.GlobalDeclaration[];
|
|
9
|
+
getOuterGlobalMacroDeclarations(): ASTNode.GlobalDeclaration[];
|
|
8
10
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { Grammar } from "./Grammar";
|
|
2
1
|
import { BaseToken } from "../common/BaseToken";
|
|
3
2
|
import { StateActionTable, StateGotoTable } from "../lalr/types";
|
|
3
|
+
import { MacroDefineList } from "../Preprocessor";
|
|
4
4
|
import { ASTNode } from "./AST";
|
|
5
|
+
import { Grammar } from "./Grammar";
|
|
5
6
|
import SematicAnalyzer from "./SemanticAnalyzer";
|
|
6
7
|
/**
|
|
7
8
|
* The syntax parser and sematic analyzer of `ShaderLab` compiler
|
|
@@ -18,6 +19,6 @@ export declare class ShaderTargetParser {
|
|
|
18
19
|
static _singleton: ShaderTargetParser;
|
|
19
20
|
static create(): ShaderTargetParser;
|
|
20
21
|
private constructor();
|
|
21
|
-
parse(tokens: Generator<BaseToken, BaseToken
|
|
22
|
+
parse(tokens: Generator<BaseToken, BaseToken>, macroDefineList: MacroDefineList): ASTNode.GLShaderProgram | null;
|
|
22
23
|
private _printStack;
|
|
23
24
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GalaceanDataType } from "../../common";
|
|
2
|
-
import { EShaderStage } from "../../common/
|
|
2
|
+
import { EShaderStage } from "../../common/enums/ShaderStage";
|
|
3
3
|
export declare enum EGenType {
|
|
4
4
|
GenType = 200,
|
|
5
5
|
GenIntType = 201,
|
|
@@ -30,5 +30,6 @@ export declare class BuiltinFunction {
|
|
|
30
30
|
static _create(ident: string, returnType: BuiltinType, ...args: BuiltinType[]): void;
|
|
31
31
|
static _createWithScop(ident: string, returnType: BuiltinType, scope: EShaderStage, ...args: BuiltinType[]): void;
|
|
32
32
|
static getFn(ident: string, parameterTypes: NonGenericGalaceanType[]): BuiltinFunction | undefined;
|
|
33
|
+
static isExist(ident: string): boolean;
|
|
33
34
|
}
|
|
34
35
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GalaceanDataType } from "../../common";
|
|
2
|
-
import { EShaderStage } from "../../common/
|
|
2
|
+
import { EShaderStage } from "../../common/enums/ShaderStage";
|
|
3
3
|
export declare const BuiltinVariableTable: Map<string, BuiltinVariable>;
|
|
4
4
|
export declare class BuiltinVariable {
|
|
5
5
|
type: GalaceanDataType;
|
|
@@ -1,18 +1,22 @@
|
|
|
1
|
-
import { IBaseSymbol } from "../../common/
|
|
1
|
+
import { IBaseSymbol } from "../../common/IBaseSymbol";
|
|
2
2
|
import { GalaceanDataType } from "../../common/types";
|
|
3
3
|
import { ASTNode } from "../AST";
|
|
4
4
|
import { SymbolDataType } from "./SymbolDataType";
|
|
5
5
|
export declare enum ESymbolType {
|
|
6
6
|
VAR = 0,
|
|
7
7
|
FN = 1,
|
|
8
|
-
STRUCT = 2
|
|
8
|
+
STRUCT = 2,
|
|
9
|
+
Any = 3
|
|
9
10
|
}
|
|
10
11
|
export type SymbolAstNode = ASTNode.Initializer | ASTNode.StructSpecifier | ASTNode.FunctionDefinition | ASTNode.ParameterDeclarator | ASTNode.InitDeclaratorList | ASTNode.VariableDeclaration;
|
|
11
12
|
export declare class SymbolInfo implements IBaseSymbol {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
ident: string;
|
|
14
|
+
type: ESymbolType;
|
|
15
|
+
astNode?: SymbolAstNode;
|
|
16
|
+
dataType?: SymbolDataType;
|
|
17
|
+
paramSignature?: GalaceanDataType[];
|
|
18
|
+
isInMacroBranch: boolean;
|
|
19
|
+
constructor(ident: string, type: ESymbolType, astNode?: SymbolAstNode, dataType?: SymbolDataType, paramSignature?: GalaceanDataType[], isInMacroBranch?: boolean);
|
|
20
|
+
set(ident: string, symbolType: ESymbolType, astNode?: SymbolAstNode, dataType?: SymbolDataType, paramSignature?: GalaceanDataType[]): void;
|
|
21
|
+
equal(symbol: SymbolInfo): boolean;
|
|
18
22
|
}
|
package/types/parser/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { NoneTerminal } from "./GrammarSymbol";
|
|
2
|
-
import { BaseToken } from "../common/BaseToken";
|
|
3
1
|
import { GalaceanDataType } from "../common";
|
|
2
|
+
import { BaseToken } from "../common/BaseToken";
|
|
4
3
|
import { ASTNode, TreeNode } from "./AST";
|
|
4
|
+
import { NoneTerminal } from "./GrammarSymbol";
|
|
5
5
|
export type TraceStackItem = NoneTerminal | BaseToken;
|
|
6
6
|
export declare class SymbolType {
|
|
7
7
|
type: GalaceanDataType;
|
|
@@ -13,11 +13,12 @@ export declare class StructProp implements IParamInfo {
|
|
|
13
13
|
typeInfo: SymbolType;
|
|
14
14
|
ident: BaseToken;
|
|
15
15
|
mrtIndex?: number;
|
|
16
|
-
|
|
16
|
+
isInMacroBranch: boolean;
|
|
17
|
+
constructor(typeInfo: SymbolType, ident: BaseToken, mrtIndex?: number, isInMacroBranch?: boolean);
|
|
17
18
|
}
|
|
18
19
|
export type NodeChild = TreeNode | BaseToken;
|
|
19
20
|
export type IParamInfo = {
|
|
20
|
-
ident
|
|
21
|
-
typeInfo
|
|
22
|
-
astNode?:
|
|
21
|
+
ident?: BaseToken;
|
|
22
|
+
typeInfo?: SymbolType;
|
|
23
|
+
astNode?: ASTNode.ParameterDeclaration | ASTNode.MacroParamBlock;
|
|
23
24
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IRenderStates, IShaderPassSource, IShaderSource, ISubShaderSource } from "@galacean/engine-design";
|
|
2
|
+
export declare class ShaderSourceFactory {
|
|
3
|
+
static createRenderStates(): IRenderStates;
|
|
4
|
+
static createShaderSource(name: string): IShaderSource;
|
|
5
|
+
static createSubShaderSource(name: string): ISubShaderSource;
|
|
6
|
+
static createShaderPassSource(name: string): IShaderPassSource;
|
|
7
|
+
static createUsePass(name: string): IShaderPassSource;
|
|
8
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IBaseSymbol } from "../common/IBaseSymbol";
|
|
2
|
+
export declare class ShaderSourceSymbol implements IBaseSymbol {
|
|
3
|
+
ident: string;
|
|
4
|
+
type: number;
|
|
5
|
+
value?: any;
|
|
6
|
+
isInMacroBranch: boolean;
|
|
7
|
+
constructor(ident: string, type: number, value?: any);
|
|
8
|
+
set(ident: string, type: number, value?: any): void;
|
|
9
|
+
equal(other: ShaderSourceSymbol): boolean;
|
|
10
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Color } from "@galacean/engine";
|
|
2
|
+
import { ShaderPosition, ShaderRange } from "../common";
|
|
3
|
+
import { BaseLexer } from "../common/BaseLexer";
|
|
4
|
+
import { BaseToken } from "../common/BaseToken";
|
|
5
|
+
export default class SourceLexer extends BaseLexer {
|
|
6
|
+
hasPendingContent: boolean;
|
|
7
|
+
private static _keywordLexemeTable;
|
|
8
|
+
private static _symbolLexemeTable;
|
|
9
|
+
private static _isWordSeparatorChar;
|
|
10
|
+
private static _scanDigits;
|
|
11
|
+
scanNumber(): number;
|
|
12
|
+
scanColor(): Color;
|
|
13
|
+
scanToken(): BaseToken;
|
|
14
|
+
scanToCharacter(char: string): void;
|
|
15
|
+
createCompileError(message: string, location?: ShaderPosition | ShaderRange): Error;
|
|
16
|
+
private _scanWord;
|
|
17
|
+
private _validateWordBoundaries;
|
|
18
|
+
private _isValidWordBoundary;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ShaderSourceParser } from "./ShaderSourceParser";
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export interface IBaseSymbol {
|
|
2
|
-
readonly ident: string;
|
|
3
|
-
}
|
|
4
|
-
/**
|
|
5
|
-
* The base class of `SymbolTable`
|
|
6
|
-
*/
|
|
7
|
-
export declare abstract class BaseSymbolTable<T extends IBaseSymbol = IBaseSymbol> {
|
|
8
|
-
protected _table: Map<string, T[]>;
|
|
9
|
-
abstract insert(sm: T): void;
|
|
10
|
-
}
|
|
11
|
-
export declare class SymbolTableStack<S extends IBaseSymbol, T extends BaseSymbolTable<S>> {
|
|
12
|
-
stack: T[];
|
|
13
|
-
get _scope(): T;
|
|
14
|
-
newScope(scope: T): void;
|
|
15
|
-
clear(): void;
|
|
16
|
-
dropScope(): void;
|
|
17
|
-
insert(sm: S): void;
|
|
18
|
-
}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
export declare enum EKeyword {
|
|
2
|
-
ATTRIBUTE = 0,
|
|
3
|
-
CONST = 1,
|
|
4
|
-
BOOL = 2,
|
|
5
|
-
FLOAT = 3,
|
|
6
|
-
DOUBLE = 4,
|
|
7
|
-
INT = 5,
|
|
8
|
-
UINT = 6,
|
|
9
|
-
BREAK = 7,
|
|
10
|
-
CONTINUE = 8,
|
|
11
|
-
DO = 9,
|
|
12
|
-
ELSE = 10,
|
|
13
|
-
FOR = 11,
|
|
14
|
-
IF = 12,
|
|
15
|
-
WHILE = 13,
|
|
16
|
-
DISCARD = 14,
|
|
17
|
-
RETURN = 15,
|
|
18
|
-
BVEC2 = 16,
|
|
19
|
-
BVEC3 = 17,
|
|
20
|
-
BVEC4 = 18,
|
|
21
|
-
IVEC2 = 19,
|
|
22
|
-
IVEC3 = 20,
|
|
23
|
-
IVEC4 = 21,
|
|
24
|
-
UVEC2 = 22,
|
|
25
|
-
UVEC3 = 23,
|
|
26
|
-
UVEC4 = 24,
|
|
27
|
-
VEC2 = 25,
|
|
28
|
-
VEC3 = 26,
|
|
29
|
-
VEC4 = 27,
|
|
30
|
-
VEC4_ARRAY = 28,
|
|
31
|
-
MAT2 = 29,
|
|
32
|
-
MAT3 = 30,
|
|
33
|
-
MAT4 = 31,
|
|
34
|
-
MAT2X3 = 32,
|
|
35
|
-
MAT2X4 = 33,
|
|
36
|
-
MAT3X2 = 34,
|
|
37
|
-
MAT3X4 = 35,
|
|
38
|
-
MAT4X2 = 36,
|
|
39
|
-
MAT4X3 = 37,
|
|
40
|
-
IN = 38,
|
|
41
|
-
OUT = 39,
|
|
42
|
-
INOUT = 40,
|
|
43
|
-
CENTROID = 41,
|
|
44
|
-
SAMPLER2D = 42,
|
|
45
|
-
SAMPLER3D = 43,
|
|
46
|
-
SAMPLER_CUBE = 44,
|
|
47
|
-
SAMPLER2D_SHADOW = 45,
|
|
48
|
-
SAMPLER_CUBE_SHADOW = 46,
|
|
49
|
-
SAMPLER2D_ARRAY = 47,
|
|
50
|
-
SAMPLER2D_ARRAY_SHADOW = 48,
|
|
51
|
-
I_SAMPLER2D = 49,
|
|
52
|
-
I_SAMPLER3D = 50,
|
|
53
|
-
I_SAMPLER_CUBE = 51,
|
|
54
|
-
I_SAMPLER2D_ARRAY = 52,
|
|
55
|
-
U_SAMPLER2D = 53,
|
|
56
|
-
U_SAMPLER3D = 54,
|
|
57
|
-
U_SAMPLER_CUBE = 55,
|
|
58
|
-
U_SAMPLER2D_ARRAY = 56,
|
|
59
|
-
STRUCT = 57,
|
|
60
|
-
LAYOUT = 58,
|
|
61
|
-
LOCATION = 59,
|
|
62
|
-
VOID = 60,
|
|
63
|
-
TRUE = 61,
|
|
64
|
-
FALSE = 62,
|
|
65
|
-
PRECISION = 63,
|
|
66
|
-
PRECISE = 64,
|
|
67
|
-
HIGHP = 65,
|
|
68
|
-
MEDIUMP = 66,
|
|
69
|
-
LOWP = 67,
|
|
70
|
-
INVARIANT = 68,
|
|
71
|
-
SMOOTH = 69,
|
|
72
|
-
FLAT = 70,
|
|
73
|
-
NOPERSPECTIVE = 71,
|
|
74
|
-
GS_RenderQueueType = 72,
|
|
75
|
-
GS_BlendState = 73,
|
|
76
|
-
GS_DepthState = 74,
|
|
77
|
-
GS_StencilState = 75,
|
|
78
|
-
GS_RasterState = 76,
|
|
79
|
-
GS_EditorProperties = 77,
|
|
80
|
-
GS_EditorMacros = 78,
|
|
81
|
-
GS_Editor = 79,
|
|
82
|
-
GS_Tags = 80,
|
|
83
|
-
GS_ReplacementTag = 81,
|
|
84
|
-
GS_LightMode = 82,
|
|
85
|
-
GS_PipelineStage = 83,
|
|
86
|
-
GS_VertexShader = 84,
|
|
87
|
-
GS_FragmentShader = 85,
|
|
88
|
-
GS_SubShader = 86,
|
|
89
|
-
GS_Pass = 87,
|
|
90
|
-
GS_BlendFactor = 88,
|
|
91
|
-
GS_BlendOperation = 89,
|
|
92
|
-
GS_Bool = 90,
|
|
93
|
-
GS_Number = 91,
|
|
94
|
-
GS_Color = 92,
|
|
95
|
-
GS_CompareFunction = 93,
|
|
96
|
-
GS_StencilOperation = 94,
|
|
97
|
-
GS_CullMode = 95,
|
|
98
|
-
GS_UsePass = 96
|
|
99
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { TokenType } from "../common";
|
|
2
|
-
import { BaseSymbolTable, IBaseSymbol } from "../common/BaseSymbolTable";
|
|
3
|
-
export interface ISymbol extends IBaseSymbol {
|
|
4
|
-
type: number;
|
|
5
|
-
value?: any;
|
|
6
|
-
}
|
|
7
|
-
export default class ContentSymbolTable extends BaseSymbolTable<ISymbol> {
|
|
8
|
-
insert(sm: ISymbol): void;
|
|
9
|
-
lookup(ident: string, type: TokenType): ISymbol | undefined;
|
|
10
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import BaseScanner from "../common/BaseScanner";
|
|
2
|
-
export default class Scanner extends BaseScanner {
|
|
3
|
-
constructor(source: string, kws?: Map<string, number>);
|
|
4
|
-
/**
|
|
5
|
-
* split by space
|
|
6
|
-
*/
|
|
7
|
-
scanWord(): string;
|
|
8
|
-
scanNumber(): number;
|
|
9
|
-
scanToCharacter(char: string): void;
|
|
10
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { ShaderContentParser } from "./ShaderContentParser";
|
package/types/lexer/Utils.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export default class LexerUtils {
|
|
2
|
-
static isNum(charCode: number): boolean;
|
|
3
|
-
static isLetter(charCode: number): boolean;
|
|
4
|
-
static isAlpha(charCode: number): boolean;
|
|
5
|
-
static isPpCharacters(charCode: number): boolean;
|
|
6
|
-
static isSpace(charCode: number): charCode is 9 | 10 | 13 | 32;
|
|
7
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { GalaceanDataType } from "../../common";
|
|
2
|
-
import { BaseSymbolTable } from "../../common/BaseSymbolTable";
|
|
3
|
-
import { ASTNode } from "../AST";
|
|
4
|
-
import { FnSymbol } from "./FnSymbol";
|
|
5
|
-
import { StructSymbol } from "./StructSymbol";
|
|
6
|
-
import { ESymbolType, SymbolInfo } from "./SymbolInfo";
|
|
7
|
-
import { VarSymbol } from "./VarSymbol";
|
|
8
|
-
export declare class TargetSymbolTable extends BaseSymbolTable<SymbolInfo> {
|
|
9
|
-
insert(sm: SymbolInfo): void;
|
|
10
|
-
lookup<T extends ESymbolType>(ident: string, symbolType: T, signature?: GalaceanDataType[], astNode?: ASTNode.FunctionDefinition): T extends ESymbolType.FN ? FnSymbol : T extends ESymbolType.STRUCT ? StructSymbol : T extends ESymbolType.VAR ? VarSymbol : SymbolInfo;
|
|
11
|
-
getAllFnSymbols(fnIdent: string): FnSymbol[];
|
|
12
|
-
private _compareWith;
|
|
13
|
-
}
|