@galacean/engine-shader-compiler 0.0.0-experimental-2.0-spine.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.
- package/LICENSE +21 -0
- package/README.md +43 -0
- package/bundler/cli.js +341 -0
- package/bundler/precompile.cjs.js +324 -0
- package/bundler/precompile.js +294 -0
- package/bundler/rollup.cjs.js +368 -0
- package/bundler/rollup.js +341 -0
- package/dist/browser.js +8938 -0
- package/dist/browser.js.map +1 -0
- package/dist/browser.min.js +2 -0
- package/dist/browser.min.js.map +1 -0
- package/dist/browser.verbose.js +9601 -0
- package/dist/browser.verbose.js.map +1 -0
- package/dist/browser.verbose.min.js +2 -0
- package/dist/browser.verbose.min.js.map +1 -0
- package/dist/main.js +8935 -0
- package/dist/main.js.map +1 -0
- package/dist/main.verbose.js +9598 -0
- package/dist/main.verbose.js.map +1 -0
- package/dist/module.js +8928 -0
- package/dist/module.js.map +1 -0
- package/dist/module.verbose.js +9591 -0
- package/dist/module.verbose.js.map +1 -0
- package/package.json +69 -0
- package/types/GSError.d.ts +16 -0
- package/types/ParserUtils.d.ts +39 -0
- package/types/Preprocessor.d.ts +30 -0
- package/types/ShaderCompiler.d.ts +21 -0
- package/types/ShaderCompilerUtils.d.ts +10 -0
- package/types/ShaderInstructionEncoder.d.ts +1 -0
- package/types/TempArray.d.ts +5 -0
- package/types/bundler/cli.d.ts +1 -0
- package/types/bundler/precompile.d.ts +25 -0
- package/types/bundler/rollup.d.ts +41 -0
- package/types/codeGen/CodeGenVisitor.d.ts +1 -0
- package/types/codeGen/GLES100.d.ts +12 -0
- package/types/codeGen/GLES300.d.ts +20 -0
- package/types/codeGen/GLESVisitor.d.ts +1 -0
- package/types/codeGen/VisitorContext.d.ts +2 -0
- package/types/codeGen/index.d.ts +3 -0
- package/types/codeGen/types.d.ts +12 -0
- package/types/common/BaseLexer.d.ts +2 -0
- package/types/common/BaseToken.d.ts +35 -0
- package/types/common/IBaseSymbol.d.ts +5 -0
- package/types/common/ShaderPosition.d.ts +8 -0
- package/types/common/ShaderRange.d.ts +8 -0
- package/types/common/SymbolTable.d.ts +9 -0
- package/types/common/SymbolTableStack.d.ts +13 -0
- package/types/common/enums/Keyword.d.ts +124 -0
- package/types/common/enums/ShaderStage.d.ts +5 -0
- package/types/common/index.d.ts +5 -0
- package/types/common/types.d.ts +101 -0
- package/types/index.d.ts +3 -0
- package/types/lalr/CFG.d.ts +5 -0
- package/types/lalr/LALR1.d.ts +27 -0
- package/types/lalr/Production.d.ts +9 -0
- package/types/lalr/State.d.ts +20 -0
- package/types/lalr/StateItem.d.ts +20 -0
- package/types/lalr/Utils.d.ts +22 -0
- package/types/lalr/index.d.ts +2 -0
- package/types/lalr/types.d.ts +14 -0
- package/types/lexer/Lexer.d.ts +143 -0
- package/types/lexer/index.d.ts +1 -0
- package/types/parser/AST.d.ts +502 -0
- package/types/parser/Grammar.d.ts +11 -0
- package/types/parser/GrammarSymbol.d.ts +128 -0
- package/types/parser/SemanticAnalyzer.d.ts +2 -0
- package/types/parser/ShaderInfo.d.ts +10 -0
- package/types/parser/ShaderTargetParser.d.ts +24 -0
- package/types/parser/builtin/functions.d.ts +34 -0
- package/types/parser/builtin/index.d.ts +2 -0
- package/types/parser/builtin/variables.d.ts +11 -0
- package/types/parser/index.d.ts +2 -0
- package/types/parser/symbolTable/FnSymbol.d.ts +6 -0
- package/types/parser/symbolTable/StructSymbol.d.ts +6 -0
- package/types/parser/symbolTable/SymbolDataType.d.ts +8 -0
- package/types/parser/symbolTable/SymbolInfo.d.ts +22 -0
- package/types/parser/symbolTable/VarSymbol.d.ts +8 -0
- package/types/parser/symbolTable/index.d.ts +6 -0
- package/types/parser/types.d.ts +24 -0
- package/types/sourceParser/ShaderSourceFactory.d.ts +8 -0
- package/types/sourceParser/ShaderSourceParser.d.ts +1 -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/verbose/package.json +11 -0
|
@@ -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;
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
}
|
|
@@ -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, 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][];
|
|
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,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,143 @@
|
|
|
1
|
+
import { BaseLexer } from "../common/BaseLexer";
|
|
2
|
+
import { BaseToken, BranchSignature } from "../common/BaseToken";
|
|
3
|
+
import { MacroDefineList } from "../Preprocessor";
|
|
4
|
+
/**
|
|
5
|
+
* The Lexer of Shader Compiler
|
|
6
|
+
*/
|
|
7
|
+
export declare class Lexer extends BaseLexer {
|
|
8
|
+
macroDefineList: MacroDefineList;
|
|
9
|
+
private static _lexemeTable;
|
|
10
|
+
private static _ifCounter;
|
|
11
|
+
/** Two branch signatures are equal iff they have the same constraints in the
|
|
12
|
+
* same order with the same polarity. Used by `#define` dedup and AST upgrade
|
|
13
|
+
* matching. */
|
|
14
|
+
static sameBranch(a: BranchSignature, b: BranchSignature): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Returns true if a `#define` registered under `defBranch` is reachable from
|
|
17
|
+
* a call site under `callSiteBranch`. Two signatures are mutually exclusive
|
|
18
|
+
* iff some flag appears in both with opposite `defined` polarity. Anything
|
|
19
|
+
* else is compatible — the same flag with the same polarity, or flags that
|
|
20
|
+
* simply don't intersect.
|
|
21
|
+
*
|
|
22
|
+
* Conservative for `#if expr` (not modeled — `tokenize` pushes a sentinel
|
|
23
|
+
* with `name === ""` to keep the `#endif` stack depth correct; that
|
|
24
|
+
* sentinel never matches a real flag in the polarity check below, so it
|
|
25
|
+
* stays visible from everywhere). Exact for the common `#ifdef` /
|
|
26
|
+
* `#ifndef` / `#else` cases that drive real shader code.
|
|
27
|
+
*/
|
|
28
|
+
static isVisibleFrom(defBranch: BranchSignature, callSiteBranch: BranchSignature): boolean;
|
|
29
|
+
private _needScanMacroConditionExpression;
|
|
30
|
+
private _inMacroDefineValue;
|
|
31
|
+
private _macroDefineExpectsNameToken;
|
|
32
|
+
private _macroDefineExpectsParamsToken;
|
|
33
|
+
private _currentMacroName;
|
|
34
|
+
private _currentMacroParamsLexeme;
|
|
35
|
+
private _currentMacroValueStart;
|
|
36
|
+
private _branchStack;
|
|
37
|
+
private _pendingBranchPushDefined;
|
|
38
|
+
tokenize(): Generator<BaseToken<number>, BaseToken<number>, unknown>;
|
|
39
|
+
constructor(source: string, macroDefineList: MacroDefineList);
|
|
40
|
+
scanToken(): BaseToken;
|
|
41
|
+
private _scanStringConst;
|
|
42
|
+
private _scanNumAfterDot;
|
|
43
|
+
private _scanUtilBreakLine;
|
|
44
|
+
private _scanDirectives;
|
|
45
|
+
/** True if the current char is an unescaped line break (ignoring `\` continuation). */
|
|
46
|
+
private _isAtLineBreak;
|
|
47
|
+
/**
|
|
48
|
+
* Walk a `#define` directive head once and produce everything both routing
|
|
49
|
+
* and registration need: name range, optional params range, value range,
|
|
50
|
+
* and whether the value parses as an `expression`.
|
|
51
|
+
*
|
|
52
|
+
* The replacement list is split three ways:
|
|
53
|
+
*
|
|
54
|
+
* - **AST path** (`isExpression = true`): value parses as `expression`.
|
|
55
|
+
* Covers identifiers, literals, parenthesized sub-expressions, operator
|
|
56
|
+
* expressions, function calls, top-level comma lists (per C99 §6.10.3).
|
|
57
|
+
*
|
|
58
|
+
* - **Legacy opaque path** (`isExpression = false`, no throw): the three
|
|
59
|
+
* GLSL-ES-§3.4-legal-but-not-an-expression shapes with real-world use —
|
|
60
|
+
* 1. empty value e.g. `#define COMMON_INCLUDED`
|
|
61
|
+
* 2. single type/qualifier keyword e.g. `#define FxaaFloat float`
|
|
62
|
+
* 3. type-qualifier list e.g. `#define TEX_PARAM(s) mediump sampler2D s`
|
|
63
|
+
*
|
|
64
|
+
* Note on X-macro support: the classical C X-macro pattern (a list
|
|
65
|
+
* macro re-expanded with redefined `X(...)`) works fine — it uses
|
|
66
|
+
* function-like macros + `\` line-continuation + `#undef`, all of
|
|
67
|
+
* which Galacean supports. It does NOT require unbalanced parens.
|
|
68
|
+
*
|
|
69
|
+
* - **Authoring error** (throws): every other shape that's not a valid
|
|
70
|
+
* `expression`. Legal token sequences in theory but not used in real
|
|
71
|
+
* GLSL — almost always author mistakes. We surface one uniform
|
|
72
|
+
* diagnostic with the macro name and value text and let the user fix
|
|
73
|
+
* their code instead of routing politely.
|
|
74
|
+
*
|
|
75
|
+
* Unsupported shapes that throw (non-exhaustive — the predicate is
|
|
76
|
+
* "the value doesn't reduce as `expression` and isn't one of the three
|
|
77
|
+
* legacy shapes above"):
|
|
78
|
+
* - leading bare punctuation `,` `;` `:` `?` `)` `]`
|
|
79
|
+
* - trailing `,` or `;` e.g. `#define X a, b,`
|
|
80
|
+
* - trailing binary / unary op `+` `-` `*` `/` `%` `&` `|` `^`
|
|
81
|
+
* `<` `>` `=` `!` `~`
|
|
82
|
+
* - trailing ternary fragment `?` or `:`
|
|
83
|
+
* - unbalanced `[` / `]` e.g. `#define X a[b`
|
|
84
|
+
* - unbalanced `(` / `)` e.g. `#define PAREN (`
|
|
85
|
+
*
|
|
86
|
+
* Returns `null` if the directive is malformed before the name. `cursor` is
|
|
87
|
+
* the position past the last non-newline char (caller advances from there).
|
|
88
|
+
*/
|
|
89
|
+
private _peekMacroDefine;
|
|
90
|
+
/** GLSL type / qualifier keywords that aren't expression starters when standing alone.
|
|
91
|
+
* `true` / `false` are excluded — they're `primary_expression` literals.
|
|
92
|
+
* `#`-prefixed entries are excluded — they're preprocessor directive names. */
|
|
93
|
+
private static _isNonExpressionLeadingKeyword;
|
|
94
|
+
/**
|
|
95
|
+
* If `i` points at a `\` immediately followed by a newline (`\n`, `\r`, or
|
|
96
|
+
* `\r\n`), return the index just past the pair (a single atom in the C/GLSL
|
|
97
|
+
* preprocessor view). Otherwise return `i` unchanged. This is the single
|
|
98
|
+
* source of truth for line-continuation detection — callers along the
|
|
99
|
+
* directive-scanning path (`_skipNonSemantic`, `_scanUtilBreakLine`,
|
|
100
|
+
* `_scanMacroDefineParams`) all delegate here so the rule stays in one
|
|
101
|
+
* place.
|
|
102
|
+
*/
|
|
103
|
+
private static _skipLineContinuation;
|
|
104
|
+
/**
|
|
105
|
+
* Pure positional version of "skip non-semantic characters within a single
|
|
106
|
+
* `#define` directive": spaces, tabs, `\` + newline line-continuation, block
|
|
107
|
+
* comments, line comments. A real `\n` (without preceding `\`) is *not*
|
|
108
|
+
* consumed — it terminates the directive — so callers can detect
|
|
109
|
+
* end-of-directive after this returns. Shared by `_defineHasValue` (peek
|
|
110
|
+
* path) and `_skipInlineSpaceAndComments` (consuming path) so both honor
|
|
111
|
+
* the same lexical view.
|
|
112
|
+
*/
|
|
113
|
+
private static _skipNonSemantic;
|
|
114
|
+
/** Consuming wrapper around `_skipNonSemantic` operating on the lexer's
|
|
115
|
+
* current position. Used by the `#define`-value scan state machine. Goes
|
|
116
|
+
* through `advance(diff)` so verbose builds keep their line/column counters
|
|
117
|
+
* in sync (advance walks the consumed slice and bumps `_line` on `\n`). */
|
|
118
|
+
private _skipInlineSpaceAndComments;
|
|
119
|
+
/**
|
|
120
|
+
* Capture a `(param1, param2, …)` block immediately after the macro name in a
|
|
121
|
+
* `#define` directive, producing a single `MACRO_DEFINE_PARAMS` token whose lexeme
|
|
122
|
+
* is the complete `(…)` text (including parens). Balanced parentheses are honored
|
|
123
|
+
* so the scanner doesn't terminate early on inner `()`. Newlines inside the
|
|
124
|
+
* parameter list are tolerated (rare; appears when the directive uses `\` line
|
|
125
|
+
* continuation), but any newline raises no special error here — it simply stops
|
|
126
|
+
* capture and parser handles the resulting token however it can.
|
|
127
|
+
*/
|
|
128
|
+
private _scanMacroDefineParams;
|
|
129
|
+
/** Emit `MACRO_DEFINE_END` at the end of a `#define` value, consuming the newline. */
|
|
130
|
+
private _emitMacroDefineEnd;
|
|
131
|
+
private _registerMacroDefine;
|
|
132
|
+
/** Render a `[start, end)` value range as space-separated significant chars,
|
|
133
|
+
* using the same comment / line-continuation rules `_skipNonSemantic`
|
|
134
|
+
* applies on the token-stream path. Used as the dedup key body. */
|
|
135
|
+
private static _normalizeValueText;
|
|
136
|
+
private _scanMacroConditionExpression;
|
|
137
|
+
private _scanWord;
|
|
138
|
+
/** True iff at least one `#define <word>` is reachable from the current branch. */
|
|
139
|
+
private _isVisibleMacro;
|
|
140
|
+
private _scanNum;
|
|
141
|
+
private _scanFloatSuffix;
|
|
142
|
+
private _scanIntegerSuffix;
|
|
143
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Lexer";
|