@galacean/engine-shaderlab 1.6.0-alpha.2 → 1.6.0-beta.0

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 (70) hide show
  1. package/dist/browser.js +6325 -4885
  2. package/dist/browser.js.map +1 -1
  3. package/dist/browser.min.js +1 -1
  4. package/dist/browser.min.js.map +1 -1
  5. package/dist/browser.verbose.js +5956 -4985
  6. package/dist/browser.verbose.js.map +1 -1
  7. package/dist/browser.verbose.min.js +1 -1
  8. package/dist/browser.verbose.min.js.map +1 -1
  9. package/dist/main.js +6325 -4885
  10. package/dist/main.js.map +1 -1
  11. package/dist/main.verbose.js +5956 -4985
  12. package/dist/main.verbose.js.map +1 -1
  13. package/dist/module.js +6325 -4887
  14. package/dist/module.js.map +1 -1
  15. package/dist/module.verbose.js +5958 -4986
  16. package/dist/module.verbose.js.map +1 -1
  17. package/package.json +4 -4
  18. package/types/GSError.d.ts +2 -1
  19. package/types/ParserUtils.d.ts +1 -1
  20. package/types/Preprocessor.d.ts +31 -0
  21. package/types/ShaderLab.d.ts +15 -1
  22. package/types/codeGen/CodeGenVisitor.d.ts +1 -2
  23. package/types/codeGen/GLES100.d.ts +4 -8
  24. package/types/codeGen/GLES300.d.ts +9 -6
  25. package/types/codeGen/types.d.ts +2 -2
  26. package/types/common/BaseLexer.d.ts +2 -0
  27. package/types/common/IBaseSymbol.d.ts +5 -0
  28. package/types/common/SymbolTable.d.ts +7 -0
  29. package/types/common/SymbolTableStack.d.ts +13 -0
  30. package/types/common/enums/Keyword.d.ts +108 -0
  31. package/types/common/index.d.ts +1 -1
  32. package/types/common/types.d.ts +4 -5
  33. package/types/index.d.ts +0 -1
  34. package/types/lalr/CFG.d.ts +1 -1
  35. package/types/lexer/Lexer.d.ts +10 -5
  36. package/types/{preprocessor → macroProcessor}/MacroDefine.d.ts +2 -2
  37. package/types/macroProcessor/MacroParserLexer.d.ts +32 -0
  38. package/types/macroProcessor/Utils.d.ts +5 -0
  39. package/types/{preprocessor → macroProcessor}/constants.d.ts +4 -6
  40. package/types/macroProcessor/index.d.ts +1 -0
  41. package/types/parser/AST.d.ts +124 -23
  42. package/types/parser/GrammarSymbol.d.ts +21 -1
  43. package/types/parser/ShaderInfo.d.ts +4 -2
  44. package/types/parser/ShaderTargetParser.d.ts +3 -2
  45. package/types/parser/builtin/functions.d.ts +2 -1
  46. package/types/parser/builtin/variables.d.ts +1 -1
  47. package/types/parser/symbolTable/SymbolInfo.d.ts +12 -8
  48. package/types/parser/symbolTable/index.d.ts +1 -1
  49. package/types/parser/types.d.ts +7 -6
  50. package/types/sourceParser/ShaderSourceFactory.d.ts +8 -0
  51. package/types/sourceParser/ShaderSourceSymbol.d.ts +10 -0
  52. package/types/sourceParser/SourceLexer.d.ts +19 -0
  53. package/types/sourceParser/index.d.ts +1 -0
  54. package/types/common/BaseScanner.d.ts +0 -2
  55. package/types/common/BaseSymbolTable.d.ts +0 -18
  56. package/types/common/Keywords.d.ts +0 -99
  57. package/types/contentParser/ContentSymbolTable.d.ts +0 -10
  58. package/types/contentParser/KeywordMap.d.ts +0 -2
  59. package/types/contentParser/Scanner.d.ts +0 -10
  60. package/types/contentParser/index.d.ts +0 -1
  61. package/types/lexer/Utils.d.ts +0 -7
  62. package/types/parser/symbolTable/TargetSymbolTable.d.ts +0 -13
  63. package/types/preprocessor/PpScanner.d.ts +0 -51
  64. package/types/preprocessor/Preprocessor.d.ts +0 -1
  65. package/types/preprocessor/Utils.d.ts +0 -10
  66. package/types/preprocessor/index.d.ts +0 -1
  67. /package/types/common/{Enums.d.ts → enums/ShaderStage.d.ts} +0 -0
  68. /package/types/{preprocessor/PpParser.d.ts → macroProcessor/MacroParser.d.ts} +0 -0
  69. /package/types/{preprocessor → macroProcessor}/sourceMap/index.d.ts +0 -0
  70. /package/types/{contentParser/ShaderContentParser.d.ts → sourceParser/ShaderSourceParser.d.ts} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@galacean/engine-shaderlab",
3
- "version": "1.6.0-alpha.2",
3
+ "version": "1.6.0-beta.0",
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": "1.6.0-alpha.2",
30
- "@galacean/engine-design": "1.6.0-alpha.2"
29
+ "@galacean/engine-design": "1.6.0-beta.0",
30
+ "@galacean/engine": "1.6.0-beta.0"
31
31
  },
32
32
  "peerDependencies": {
33
- "@galacean/engine": "1.6.0-alpha.2"
33
+ "@galacean/engine": "1.6.0-beta.0"
34
34
  },
35
35
  "scripts": {
36
36
  "b:types": "tsc"
@@ -11,5 +11,6 @@ export declare class GSError extends Error {
11
11
  export declare enum GSErrorName {
12
12
  PreprocessorError = "PreprocessorError",
13
13
  CompilationError = "CompilationError",
14
- ScannerError = "ScannerError"
14
+ ScannerError = "ScannerError",
15
+ CompilationWarn = "CompilationWarning"
15
16
  }
@@ -1,6 +1,6 @@
1
- import { NoneTerminal, GrammarSymbol } from "./parser/GrammarSymbol";
2
1
  import { GalaceanDataType } from "./common";
3
2
  import { TreeNode } from "./parser/AST";
3
+ import { GrammarSymbol, NoneTerminal } from "./parser/GrammarSymbol";
4
4
  export declare class ParserUtils {
5
5
  static unwrapNodeByType<T = TreeNode>(node: TreeNode, type: NoneTerminal): T | undefined;
6
6
  /**
@@ -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
+ }
@@ -1 +1,15 @@
1
- export {};
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
+ }
@@ -1,2 +1 @@
1
- export declare const V3_GL_FragColor = "GS_glFragColor";
2
- export declare const V3_GL_FragData = "GS_glFragData";
1
+ export {};
@@ -1,16 +1,12 @@
1
1
  import { ASTNode } from "../parser/AST";
2
+ import { StructProp } from "../parser/types";
2
3
  import { GLESVisitor } from "./GLESVisitor";
3
- import { ICodeSegment } from "./types";
4
4
  export declare class GLES100Visitor extends GLESVisitor {
5
- _versionText: string;
6
- _extensions: string;
7
5
  private static _singleton;
8
6
  static getVisitor(): GLES100Visitor;
9
- getFragDataCodeGen(index: string | number): string;
10
- getReferencedMRTPropText(index: string | number, ident: string): string;
11
- getAttributeDeclare(out: ICodeSegment[]): void;
12
- getVaryingDeclare(out: ICodeSegment[]): void;
13
- getMRTDeclare(out: ICodeSegment[]): void;
7
+ getAttributeProp(prop: StructProp): string;
8
+ getVaryingProp(prop: StructProp): string;
9
+ getMRTProp(): string;
14
10
  visitPostfixExpression(node: ASTNode.PostfixExpression): string;
15
11
  visitJumpStatement(node: ASTNode.JumpStatement): string;
16
12
  }
@@ -1,15 +1,18 @@
1
1
  import { ASTNode } from "../parser/AST";
2
+ import { ShaderData } from "../parser/ShaderInfo";
3
+ import { StructProp } from "../parser/types";
2
4
  import { GLESVisitor } from "./GLESVisitor";
3
5
  import { ICodeSegment } from "./types";
4
6
  export declare class GLES300Visitor extends GLESVisitor {
5
- _versionText: string;
6
7
  private static _singleton;
7
8
  static getVisitor(): GLES300Visitor;
8
- getFragDataCodeGen(index: string | number): string;
9
- getReferencedMRTPropText(index: string | number, ident: string): string;
10
- getAttributeDeclare(out: ICodeSegment[]): void;
11
- getVaryingDeclare(out: ICodeSegment[]): void;
12
- getMRTDeclare(out: ICodeSegment[]): void;
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;
13
16
  visitFunctionIdentifier(node: ASTNode.FunctionIdentifier): string;
14
17
  visitVariableIdentifier(node: ASTNode.VariableIdentifier): string;
15
18
  visitJumpStatement(node: ASTNode.JumpStatement): string;
@@ -1,11 +1,11 @@
1
- import { IShaderContent } from "@galacean/engine-design";
1
+ import { IShaderSource } from "@galacean/engine-design";
2
2
  export type IRenderState = [
3
3
  /** Constant RenderState. */
4
4
  Record<number, boolean | string | number | any>,
5
5
  /** Variable RenderState. */
6
6
  Record<number, string>
7
7
  ];
8
- export type ITag = IShaderContent["subShaders"][number]["tags"];
8
+ export type ITag = IShaderSource["subShaders"][number]["tags"];
9
9
  export type ICodeSegment = {
10
10
  text: string;
11
11
  index: number;
@@ -0,0 +1,2 @@
1
+ import { BaseToken } from "./BaseToken";
2
+ export type OnToken = (token: BaseToken, scanner: BaseLexer) => void;
@@ -0,0 +1,5 @@
1
+ export interface IBaseSymbol {
2
+ isInMacroBranch: boolean;
3
+ readonly ident: string;
4
+ equal(other: IBaseSymbol): boolean;
5
+ }
@@ -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
+ }
@@ -2,4 +2,4 @@ import { ShaderRange } from "./ShaderRange";
2
2
  import { ShaderPosition } from "./ShaderPosition";
3
3
  export { ShaderRange, ShaderPosition };
4
4
  export * from "./types";
5
- export * from "./Keywords";
5
+ export * from "./enums/Keyword";
@@ -1,5 +1,4 @@
1
- import { EKeyword } from "./Keywords";
2
- export declare const KeywordTable: Map<string, EKeyword>;
1
+ import { Keyword } from "./enums/Keyword";
3
2
  export declare enum ETokenType {
4
3
  ID = 1000,
5
4
  FLOAT_CONSTANT = 1001,
@@ -92,11 +91,11 @@ export declare enum ETokenType {
92
91
  AMPERSAND = 1047,
93
92
  /** ? */
94
93
  QUESTION = 1048,
95
- NOT_WORD = 1049,
94
+ NotWord = 1049,
96
95
  /** ε */
97
96
  EPSILON = 1998,
98
97
  EOF = 1999
99
98
  }
100
99
  export declare const TypeAny = 3000;
101
- export type GalaceanDataType = EKeyword.VOID | EKeyword.FLOAT | EKeyword.BOOL | EKeyword.INT | EKeyword.UINT | EKeyword.VEC2 | EKeyword.VEC3 | EKeyword.VEC4 | EKeyword.BVEC2 | EKeyword.BVEC3 | EKeyword.BVEC4 | EKeyword.IVEC2 | EKeyword.IVEC3 | EKeyword.IVEC4 | EKeyword.UVEC2 | EKeyword.UVEC3 | EKeyword.UVEC4 | EKeyword.MAT2 | EKeyword.MAT3 | EKeyword.MAT4 | EKeyword.MAT2X3 | EKeyword.MAT2X4 | EKeyword.MAT3X2 | EKeyword.MAT3X4 | EKeyword.MAT4X2 | EKeyword.MAT4X3 | EKeyword.SAMPLER2D | EKeyword.SAMPLER3D | EKeyword.SAMPLER_CUBE | EKeyword.SAMPLER2D_SHADOW | EKeyword.SAMPLER_CUBE_SHADOW | EKeyword.SAMPLER2D_ARRAY | EKeyword.SAMPLER2D_ARRAY_SHADOW | EKeyword.I_SAMPLER2D | EKeyword.I_SAMPLER3D | EKeyword.I_SAMPLER_CUBE | EKeyword.I_SAMPLER2D_ARRAY | EKeyword.U_SAMPLER2D | EKeyword.U_SAMPLER3D | EKeyword.U_SAMPLER_CUBE | EKeyword.U_SAMPLER2D_ARRAY | EKeyword.VEC4_ARRAY | typeof TypeAny | string;
102
- export type TokenType = ETokenType | EKeyword;
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;
package/types/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  export { ShaderLab } from "./ShaderLab";
2
- export { Preprocessor } from "./preprocessor";
3
2
  export * from "./GSError";
4
3
  export declare const version = "__buildVersion";
@@ -2,4 +2,4 @@ import { Grammar } from "../parser/Grammar";
2
2
  import SemanticAnalyzer from "../parser/SemanticAnalyzer";
3
3
  declare const createGrammar: () => Grammar;
4
4
  declare const addTranslationRule: (sa: SemanticAnalyzer) => void;
5
- export { createGrammar, addTranslationRule };
5
+ export { addTranslationRule, createGrammar };
@@ -1,16 +1,21 @@
1
+ import { BaseLexer } from "../common/BaseLexer";
1
2
  import { BaseToken } from "../common/BaseToken";
2
- import BaseScanner from "../common/BaseScanner";
3
+ import { MacroDefineList } from "../Preprocessor";
3
4
  /**
4
5
  * The Lexer of ShaderLab Compiler
5
6
  */
6
- export declare class Lexer extends BaseScanner {
7
- reset(source: string): void;
7
+ export declare class Lexer extends BaseLexer {
8
+ macroDefineList: MacroDefineList;
9
+ private static _lexemeTable;
10
+ private _needScanMacroConditionExpression;
8
11
  tokenize(): Generator<BaseToken<number>, BaseToken<number>, unknown>;
9
- skipSpace(): void;
12
+ constructor(source: string, macroDefineList: MacroDefineList);
10
13
  scanToken(): BaseToken;
11
14
  private _scanStringConst;
12
15
  private _scanNumAfterDot;
13
- private _getPosition;
16
+ private _scanUtilBreakLine;
17
+ private _scanDirectives;
18
+ private _scanMacroConditionExpression;
14
19
  private _scanWord;
15
20
  private _scanNum;
16
21
  private _scanFloatSuffix;
@@ -1,12 +1,12 @@
1
- import { BaseToken } from "../common/BaseToken";
2
1
  import { ShaderRange } from "../common";
2
+ import { BaseToken } from "../common/BaseToken";
3
3
  export declare class MacroDefine {
4
4
  readonly macro: BaseToken;
5
5
  readonly body?: BaseToken;
6
6
  readonly location?: ShaderRange;
7
7
  readonly args?: BaseToken[];
8
8
  private _replaceRegex?;
9
- private readonly _argsLexemes;
9
+ private readonly _argsLexemes?;
10
10
  get isFunction(): boolean;
11
11
  constructor(macro: BaseToken, body?: BaseToken, location?: ShaderRange, args?: BaseToken[]);
12
12
  expandFunctionBody(args: string[]): string;
@@ -0,0 +1,32 @@
1
+ import { ShaderPosition, ShaderRange } from "../common";
2
+ import PpSourceMap from "./sourceMap";
3
+ import { BaseLexer } from "../common/BaseLexer";
4
+ import { BaseToken } from "../common/BaseToken";
5
+ import { MacroParserToken } from "./constants";
6
+ export type OnToken = (token: BaseToken, scanner: MacroParserLexer) => void;
7
+ export default class MacroParserLexer extends BaseLexer {
8
+ private static _isPpCharacters;
9
+ private static _lexemeTable;
10
+ private macroLvl;
11
+ readonly sourceMap: PpSourceMap;
12
+ readonly file: string;
13
+ readonly blockRange?: ShaderRange;
14
+ constructor(source: string, file?: string, blockRange?: ShaderRange);
15
+ scanWordsUntilTerminator(terminatorChar: string): BaseToken[];
16
+ scanWord(): BaseToken;
17
+ scanToken(): BaseToken | undefined;
18
+ scanQuotedString(): BaseToken<MacroParserToken.string_const>;
19
+ scanToChar(char: string): void;
20
+ scanMacroBranchBody(): {
21
+ body: BaseToken<MacroParserToken.chunk>;
22
+ nextDirective: BaseToken;
23
+ };
24
+ scanPairedBlock(lc: string, rc: string): void;
25
+ /**
26
+ * @returns end ShaderPosition
27
+ */
28
+ scanRemainMacro(): ShaderPosition;
29
+ peekNonSpace(): string;
30
+ scanInteger(): BaseToken<number>;
31
+ scanMacroBody(): BaseToken<MacroParserToken.line_remain>;
32
+ }
@@ -0,0 +1,5 @@
1
+ import { ExpandSegment } from "./MacroParser";
2
+ import PpSourceMap from "./sourceMap";
3
+ export declare class PpUtils {
4
+ static expand(segments: ExpandSegment[], source: string, sourceMap?: PpSourceMap): string;
5
+ }
@@ -1,4 +1,4 @@
1
- export declare enum EPpToken {
1
+ export declare enum MacroParserToken {
2
2
  id = 0,
3
3
  line_remain = 1,
4
4
  chunk = 2,
@@ -40,7 +40,7 @@ export declare enum EPpToken {
40
40
  percent = 22,
41
41
  EOF = 100
42
42
  }
43
- export declare enum EPpKeyword {
43
+ export declare enum MacroParserKeyword {
44
44
  define = 101,
45
45
  undef = 102,
46
46
  if = 103,
@@ -49,8 +49,6 @@ export declare enum EPpKeyword {
49
49
  else = 106,
50
50
  elif = 107,
51
51
  endif = 108,
52
- include = 109,
53
- defined = 110
52
+ defined = 109
54
53
  }
55
- export declare const PpKeyword: Map<string, EPpKeyword>;
56
- export type PpConstant = boolean | number;
54
+ export type MacroParserConstant = boolean | number;
@@ -0,0 +1 @@
1
+ export * from "./MacroParser";