@galacean/engine-shader-compiler 2.0.0-alpha.31

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 (84) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +43 -0
  3. package/dist/browser.js +8720 -0
  4. package/dist/browser.js.map +1 -0
  5. package/dist/browser.min.js +2 -0
  6. package/dist/browser.min.js.map +1 -0
  7. package/dist/browser.verbose.js +9385 -0
  8. package/dist/browser.verbose.js.map +1 -0
  9. package/dist/browser.verbose.min.js +2 -0
  10. package/dist/browser.verbose.min.js.map +1 -0
  11. package/dist/bundler/cli.js +339 -0
  12. package/dist/bundler/rollup.cjs.js +366 -0
  13. package/dist/bundler/rollup.js +339 -0
  14. package/dist/main.js +8717 -0
  15. package/dist/main.js.map +1 -0
  16. package/dist/main.verbose.js +9382 -0
  17. package/dist/main.verbose.js.map +1 -0
  18. package/dist/module.js +8710 -0
  19. package/dist/module.js.map +1 -0
  20. package/dist/module.verbose.js +9375 -0
  21. package/dist/module.verbose.js.map +1 -0
  22. package/package.json +63 -0
  23. package/types/GSError.d.ts +16 -0
  24. package/types/ParserUtils.d.ts +26 -0
  25. package/types/Preprocessor.d.ts +33 -0
  26. package/types/ShaderCompiler.d.ts +21 -0
  27. package/types/ShaderCompilerUtils.d.ts +10 -0
  28. package/types/ShaderInstructionEncoder.d.ts +1 -0
  29. package/types/TempArray.d.ts +5 -0
  30. package/types/bundler/cli.d.ts +1 -0
  31. package/types/bundler/precompile.d.ts +25 -0
  32. package/types/bundler/rollup.d.ts +41 -0
  33. package/types/codeGen/CodeGenVisitor.d.ts +1 -0
  34. package/types/codeGen/GLES100.d.ts +12 -0
  35. package/types/codeGen/GLES300.d.ts +20 -0
  36. package/types/codeGen/GLESVisitor.d.ts +1 -0
  37. package/types/codeGen/VisitorContext.d.ts +2 -0
  38. package/types/codeGen/index.d.ts +3 -0
  39. package/types/codeGen/types.d.ts +12 -0
  40. package/types/common/BaseLexer.d.ts +2 -0
  41. package/types/common/BaseToken.d.ts +35 -0
  42. package/types/common/IBaseSymbol.d.ts +5 -0
  43. package/types/common/ShaderPosition.d.ts +8 -0
  44. package/types/common/ShaderRange.d.ts +8 -0
  45. package/types/common/SymbolTable.d.ts +9 -0
  46. package/types/common/SymbolTableStack.d.ts +13 -0
  47. package/types/common/enums/Keyword.d.ts +124 -0
  48. package/types/common/enums/ShaderStage.d.ts +5 -0
  49. package/types/common/index.d.ts +5 -0
  50. package/types/common/types.d.ts +101 -0
  51. package/types/index.d.ts +3 -0
  52. package/types/lalr/CFG.d.ts +5 -0
  53. package/types/lalr/LALR1.d.ts +26 -0
  54. package/types/lalr/Production.d.ts +9 -0
  55. package/types/lalr/State.d.ts +20 -0
  56. package/types/lalr/StateItem.d.ts +20 -0
  57. package/types/lalr/Utils.d.ts +22 -0
  58. package/types/lalr/index.d.ts +2 -0
  59. package/types/lalr/types.d.ts +14 -0
  60. package/types/lexer/Lexer.d.ts +111 -0
  61. package/types/lexer/index.d.ts +1 -0
  62. package/types/parser/AST.d.ts +482 -0
  63. package/types/parser/Grammar.d.ts +11 -0
  64. package/types/parser/GrammarSymbol.d.ts +128 -0
  65. package/types/parser/SemanticAnalyzer.d.ts +2 -0
  66. package/types/parser/ShaderInfo.d.ts +10 -0
  67. package/types/parser/ShaderTargetParser.d.ts +24 -0
  68. package/types/parser/builtin/functions.d.ts +34 -0
  69. package/types/parser/builtin/index.d.ts +2 -0
  70. package/types/parser/builtin/variables.d.ts +11 -0
  71. package/types/parser/index.d.ts +2 -0
  72. package/types/parser/symbolTable/FnSymbol.d.ts +6 -0
  73. package/types/parser/symbolTable/StructSymbol.d.ts +6 -0
  74. package/types/parser/symbolTable/SymbolDataType.d.ts +8 -0
  75. package/types/parser/symbolTable/SymbolInfo.d.ts +22 -0
  76. package/types/parser/symbolTable/VarSymbol.d.ts +8 -0
  77. package/types/parser/symbolTable/index.d.ts +6 -0
  78. package/types/parser/types.d.ts +24 -0
  79. package/types/sourceParser/ShaderSourceFactory.d.ts +8 -0
  80. package/types/sourceParser/ShaderSourceParser.d.ts +1 -0
  81. package/types/sourceParser/ShaderSourceSymbol.d.ts +10 -0
  82. package/types/sourceParser/SourceLexer.d.ts +19 -0
  83. package/types/sourceParser/index.d.ts +1 -0
  84. package/verbose/package.json +11 -0
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "@galacean/engine-shader-compiler",
3
+ "version": "2.0.0-alpha.31",
4
+ "publishConfig": {
5
+ "access": "public",
6
+ "registry": "https://registry.npmjs.org"
7
+ },
8
+ "repository": {
9
+ "url": "https://github.com/galacean/engine.git"
10
+ },
11
+ "license": "MIT",
12
+ "main": "dist/main.js",
13
+ "module": "dist/module.js",
14
+ "browser": "dist/browser.min.js",
15
+ "debug": "src/index.ts",
16
+ "types": "types/index.d.ts",
17
+ "exports": {
18
+ ".": {
19
+ "import": "./dist/module.js",
20
+ "require": "./dist/main.js",
21
+ "types": "./types/index.d.ts"
22
+ },
23
+ "./bundler/rollup": {
24
+ "import": "./dist/bundler/rollup.js",
25
+ "require": "./dist/bundler/rollup.cjs.js",
26
+ "types": "./types/bundler/rollup.d.ts"
27
+ },
28
+ "./verbose": {
29
+ "import": "./dist/module.verbose.js",
30
+ "require": "./dist/main.verbose.js",
31
+ "types": "./types/index.d.ts"
32
+ },
33
+ "./src/*": "./src/*.ts",
34
+ "./package.json": "./package.json"
35
+ },
36
+ "bin": {
37
+ "shader-compiler-precompile": "./dist/bundler/cli.js"
38
+ },
39
+ "umd": {
40
+ "name": "Galacean.ShaderCompiler",
41
+ "globals": {
42
+ "@galacean/engine-math": "Galacean",
43
+ "@galacean/engine-core": "Galacean"
44
+ }
45
+ },
46
+ "files": [
47
+ "dist/**/*",
48
+ "types/**/*",
49
+ "verbose/package.json"
50
+ ],
51
+ "dependencies": {
52
+ "@rollup/pluginutils": "^5.0.0",
53
+ "@galacean/engine-core": "2.0.0-alpha.31",
54
+ "@galacean/engine-math": "2.0.0-alpha.31"
55
+ },
56
+ "devDependencies": {
57
+ "@galacean/engine-design": "2.0.0-alpha.31"
58
+ },
59
+ "scripts": {
60
+ "build": "rollup -c rollup.config.js && chmod +x dist/bundler/cli.js",
61
+ "b:types": "tsc"
62
+ }
63
+ }
@@ -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,26 @@
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
+ * Parse a function-macro parameter-list lexeme (`"(a, b, c)"`) into its parameter
8
+ * names. An empty list `"()"` yields `[]`. Leading/trailing whitespace around each
9
+ * name is trimmed. Empty entries from consecutive commas are filtered out.
10
+ */
11
+ static parseMacroParamList(lexeme: string): string[];
12
+ /**
13
+ * Return the lexeme of `expr` when it is (transitively) a single bare identifier
14
+ * wrapped in primary/postfix expression nodes, e.g. `o` → "o". Returns null for
15
+ * compound expressions (`o.x`, `foo(..)`, `arr[0]`, …). Useful for callers that
16
+ * want to apply a substitution rule only at the root of an expression, never on
17
+ * swizzles or nested member access.
18
+ */
19
+ static extractDirectIdentLexeme(expr: TreeNode): string | null;
20
+ /**
21
+ * Check if type `tb` is compatible with type `ta`.
22
+ */
23
+ static typeCompatible(ta: GalaceanDataType, tb: GalaceanDataType | undefined): boolean;
24
+ static toString(sm: GrammarSymbol): string;
25
+ static isTerminal(sm: GrammarSymbol): boolean;
26
+ }
@@ -0,0 +1,33 @@
1
+ import type { ASTNode } from "./parser/AST";
2
+ import type { BranchSignature } from "./common/BaseToken";
3
+ export type IncludeMap = {
4
+ readonly [includeName: string]: string | undefined;
5
+ };
6
+ export type ChunkOutputCache = Map<string, string>;
7
+ /**
8
+ * Record for a single `#define` directive. `valueAst` is set for expression
9
+ * macros (joined into the AST pipeline); opaque macros leave it undefined and
10
+ * are emitted verbatim to the GLSL driver.
11
+ */
12
+ export interface MacroDefineInfo {
13
+ isFunction: boolean;
14
+ name: string;
15
+ params: string[];
16
+ valueAst?: ASTNode.AssignmentExpression;
17
+ /** Leading identifier of the value (`#define F foo` → `foo`, `#define F foo(a)`
18
+ * → `foo`), or empty for literals / operator expressions. Drives symbol-table
19
+ * lookup at macro call sites. */
20
+ referenceName: string;
21
+ /** Branch signature at the point of registration. The same `#define` repeated
22
+ * in different `#ifdef` branches produces multiple entries with different
23
+ * signatures; call sites filter to those visible from their own position. */
24
+ branch: BranchSignature;
25
+ }
26
+ export interface MacroDefineList {
27
+ [macroName: string]: MacroDefineInfo[];
28
+ }
29
+ export declare class Preprocessor {
30
+ private static readonly _includeReg;
31
+ static parse(source: string, basePathForIncludeKey: string, includeMap: IncludeMap, chunkOutputCache: ChunkOutputCache): string;
32
+ private static _replace;
33
+ }
@@ -0,0 +1,21 @@
1
+ import { ShaderLanguage } from "@galacean/engine-core";
2
+ import type { IPrecompiledShader, IShaderSource } from "@galacean/engine-design";
3
+ import type { IShaderProgramSource } from "@galacean/engine-design/types/shader-compiler/IShaderProgramSource";
4
+ import { ShaderPosition, ShaderRange } from "./common";
5
+ import { IncludeMap } from "./Preprocessor";
6
+ export declare class ShaderCompiler {
7
+ private static _parser;
8
+ private static _shaderPositionPool;
9
+ private static _shaderRangePool;
10
+ static _processingPassText?: string;
11
+ private _includeMap;
12
+ private readonly _chunkOutputCache;
13
+ /** Replace the `#include` lookup table and clear the derived chunk cache. */
14
+ _setIncludeMap(includeMap: IncludeMap): void;
15
+ static createPosition(index: number, line?: number, column?: number): ShaderPosition;
16
+ static createRange(start: ShaderPosition, end: ShaderPosition): ShaderRange;
17
+ _parseShaderSource(sourceCode: string): IShaderSource;
18
+ _parseShaderPass(source: string, vertexEntry: string, fragmentEntry: string, backend: ShaderLanguage, basePathForIncludeKey: string): IShaderProgramSource | undefined;
19
+ _precompile(sourceCode: string, platformTarget: ShaderLanguage, basePathForIncludeKey: string): IPrecompiledShader;
20
+ private _serializeRenderStates;
21
+ }
@@ -0,0 +1,10 @@
1
+ import { ClearableObjectPool, type IPoolElement } from "@galacean/engine-core";
2
+ import { GSErrorName } from "./GSError";
3
+ import { ShaderRange } from "./common/ShaderRange";
4
+ import { ShaderPosition } from "./common/ShaderPosition";
5
+ export declare class ShaderCompilerUtils {
6
+ private static _shaderCompilerObjectPoolSet;
7
+ static createObjectPool<T extends IPoolElement>(type: new () => T): ClearableObjectPool<T>;
8
+ static clearAllShaderCompilerObjectPool(): void;
9
+ static createGSError(message: string, errorName: GSErrorName, source: string, location: ShaderRange | ShaderPosition, file?: string): Error | undefined;
10
+ }
@@ -0,0 +1 @@
1
+ export type { ShaderInstruction } from "@galacean/engine-design";
@@ -0,0 +1,5 @@
1
+ import type { IPoolElement } from "@galacean/engine-core";
2
+ export declare class TempArray<T> implements IPoolElement {
3
+ array: Array<T>;
4
+ dispose(): void;
5
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,25 @@
1
+ /** Normalize to forward slashes (Windows uses `\`; downstream regex/keys assume `/`). */
2
+ export declare function normalizePath(p: string): string;
3
+ export interface PrecompileOptions {
4
+ /** Absolute or relative path to the directory containing `.shader` sources. */
5
+ input: string;
6
+ /** Absolute or relative path to the directory where `.shaderc` outputs are written. */
7
+ output: string;
8
+ /** Remove `.shaderc` files whose `.shader` source no longer exists, and prune empty dirs. */
9
+ clean?: boolean;
10
+ /** Watch the input dir and re-run incrementally on `.shader` / `.glsl` changes. */
11
+ watch?: boolean;
12
+ /** Compile only this file (path may be relative to cwd). Skips full scan + cleanup. */
13
+ only?: string;
14
+ /** Generate `<output>/index.ts` aggregating every `.shaderc` file. */
15
+ emitIndex?: boolean;
16
+ /** Generate raw-source indexes: `<input>/index.ts` (.shader) + sibling `ShaderLibrary/index.ts` (.glsl). */
17
+ emitSources?: boolean;
18
+ /** Optional shader platform target passed through to `_precompile`. Defaults to `0`. */
19
+ platformTarget?: number;
20
+ }
21
+ export declare function precompile(options: PrecompileOptions): Promise<void>;
22
+ export declare function runFull(options: Omit<PrecompileOptions, "watch">): Promise<{
23
+ failed: number;
24
+ }>;
25
+ export declare function startWatcher(options: Omit<PrecompileOptions, "watch" | "only">): Promise<void>;
@@ -0,0 +1,41 @@
1
+ import type { Plugin } from "rollup";
2
+ export interface ShaderPrecompileOptions {
3
+ /** Directory containing `.shader` source files. */
4
+ input: string;
5
+ /** Directory where `.shaderc` outputs are written. */
6
+ output: string;
7
+ /** Remove `.shaderc` whose source no longer exists. Default `true`. */
8
+ clean?: boolean;
9
+ /** Emit an aggregated `<output>/index.ts`. Default `true`. */
10
+ emitIndex?: boolean;
11
+ /** Emit raw-source indexes (`.shader` + `.glsl`) into the input tree. */
12
+ emitSources?: boolean;
13
+ /** Shader platform target. Default `0`. */
14
+ platformTarget?: number;
15
+ }
16
+ export interface ShaderPluginOptions {
17
+ /**
18
+ * Override the default include pattern. The plugin always matches `.glsl`,
19
+ * `.shader`, and `.shaderc` extensions; this option exists for advanced
20
+ * cases where the host bundler needs to gate by additional path constraints.
21
+ * Returning `false` skips a file.
22
+ */
23
+ filter?: (id: string) => boolean;
24
+ /**
25
+ * When set, the plugin runs an initial full precompile in `buildStart` and,
26
+ * in watch mode, starts a background file watcher that incrementally
27
+ * regenerates `.shaderc` outputs when `.shader` / `.glsl` files change.
28
+ * Without this option the plugin only does file-extension transforms —
29
+ * pre-compile must be triggered separately via the `shader-precompile` CLI.
30
+ */
31
+ precompile?: ShaderPrecompileOptions;
32
+ }
33
+ /**
34
+ * Rollup plugin that transforms shader assets into JS modules.
35
+ *
36
+ * - Always: transforms `.glsl` / `.shader` / `.shaderc` files.
37
+ * - When `precompile` option is set: runs a full precompile in buildStart and,
38
+ * in watch mode, starts a background watcher that mirrors `.shader` source
39
+ * changes into `.shaderc` outputs and refreshes the aggregated index.
40
+ */
41
+ export declare function shaderCompiler(options?: ShaderPluginOptions): Plugin;
@@ -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,2 @@
1
+ /** Role of a struct type in the shader compiler's IO flattening. */
2
+ export type StructRole = "varying" | "attribute" | "mrt";
@@ -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 type { 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,35 @@
1
+ import { ShaderRange, ShaderPosition } from ".";
2
+ import type { IPoolElement } from "@galacean/engine-core";
3
+ /**
4
+ * One condition in a branch signature: `defined: true` for `#ifdef X` (the
5
+ * branch is active when `X` is defined), `defined: false` for `#ifndef X` /
6
+ * after `#else` (active when `X` is undefined).
7
+ */
8
+ export interface BranchConstraint {
9
+ name: string;
10
+ defined: boolean;
11
+ }
12
+ /**
13
+ * Snapshot of the `#ifdef`/`#ifndef`/`#else` stack at a source position. An
14
+ * empty signature means unconditional (top-level). Constraints are conjunctive:
15
+ * the position is active iff every constraint holds. Produced by the Lexer
16
+ * (the sole branch-stack maintainer) and stamped onto every emitted token +
17
+ * every registered `MacroDefineInfo`.
18
+ */
19
+ export type BranchSignature = readonly BranchConstraint[];
20
+ export declare const EMPTY_BRANCH: BranchSignature;
21
+ export declare class BaseToken<T extends number = number> implements IPoolElement {
22
+ static pool: import("@galacean/engine-core").ClearableObjectPool<BaseToken<number>>;
23
+ type: T;
24
+ lexeme: string;
25
+ location: ShaderRange;
26
+ /** Branch signature snapshot at the point this token was emitted. Empty
27
+ * signature (default) means top-level / unconditional. The Lexer tags
28
+ * every token; downstream code (AST nodes built from tokens) can read
29
+ * the field directly to know which `#ifdef` branch they're inside. */
30
+ branch: BranchSignature;
31
+ set(type: T, lexeme: string, start?: ShaderPosition): any;
32
+ set(type: T, lexeme: string, location?: ShaderRange): any;
33
+ dispose(): void;
34
+ }
35
+ export declare const EOF: BaseToken<number>;
@@ -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 type { IPoolElement } from "@galacean/engine-core";
2
+ export declare class ShaderPosition implements IPoolElement {
3
+ index: number;
4
+ line: number;
5
+ column: number;
6
+ set(index: number, line: number, column: number): void;
7
+ dispose(): void;
8
+ }
@@ -0,0 +1,8 @@
1
+ import type { IPoolElement } from "@galacean/engine-core";
2
+ import { ShaderPosition } from "./ShaderPosition";
3
+ export declare class ShaderRange implements IPoolElement {
4
+ start: ShaderPosition;
5
+ end: ShaderPosition;
6
+ set(start: ShaderPosition, end: ShaderPosition): void;
7
+ dispose(): void;
8
+ }
@@ -0,0 +1,9 @@
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
+ /** Iterate every registered symbol. Order within a name bucket is insertion order. */
8
+ forEach(callback: (symbol: T) => void): void;
9
+ }
@@ -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,124 @@
1
+ export declare enum Keyword {
2
+ CONST = 0,
3
+ BOOL = 1,
4
+ FLOAT = 2,
5
+ DOUBLE = 3,
6
+ INT = 4,
7
+ UINT = 5,
8
+ BREAK = 6,
9
+ CONTINUE = 7,
10
+ DO = 8,
11
+ ELSE = 9,
12
+ FOR = 10,
13
+ IF = 11,
14
+ WHILE = 12,
15
+ DISCARD = 13,
16
+ RETURN = 14,
17
+ BVEC2 = 15,
18
+ BVEC3 = 16,
19
+ BVEC4 = 17,
20
+ IVEC2 = 18,
21
+ IVEC3 = 19,
22
+ IVEC4 = 20,
23
+ UVEC2 = 21,
24
+ UVEC3 = 22,
25
+ UVEC4 = 23,
26
+ VEC2 = 24,
27
+ VEC3 = 25,
28
+ VEC4 = 26,
29
+ VEC4_ARRAY = 27,
30
+ MAT2 = 28,
31
+ MAT3 = 29,
32
+ MAT4 = 30,
33
+ MAT2X3 = 31,
34
+ MAT2X4 = 32,
35
+ MAT3X2 = 33,
36
+ MAT3X4 = 34,
37
+ MAT4X2 = 35,
38
+ MAT4X3 = 36,
39
+ IN = 37,
40
+ OUT = 38,
41
+ INOUT = 39,
42
+ CENTROID = 40,
43
+ SAMPLER2D = 41,
44
+ SAMPLER3D = 42,
45
+ SAMPLER_CUBE = 43,
46
+ SAMPLER2D_SHADOW = 44,
47
+ SAMPLER_CUBE_SHADOW = 45,
48
+ SAMPLER2D_ARRAY = 46,
49
+ SAMPLER2D_ARRAY_SHADOW = 47,
50
+ I_SAMPLER2D = 48,
51
+ I_SAMPLER3D = 49,
52
+ I_SAMPLER_CUBE = 50,
53
+ I_SAMPLER2D_ARRAY = 51,
54
+ U_SAMPLER2D = 52,
55
+ U_SAMPLER3D = 53,
56
+ U_SAMPLER_CUBE = 54,
57
+ U_SAMPLER2D_ARRAY = 55,
58
+ STRUCT = 56,
59
+ LAYOUT = 57,
60
+ LOCATION = 58,
61
+ VOID = 59,
62
+ PRECISION = 60,
63
+ PRECISE = 61,
64
+ HIGHP = 62,
65
+ MEDIUMP = 63,
66
+ LOWP = 64,
67
+ INVARIANT = 65,
68
+ SMOOTH = 66,
69
+ FLAT = 67,
70
+ NOPERSPECTIVE = 68,
71
+ True = 69,
72
+ False = 70,
73
+ LeftBrace = 71,
74
+ RightBrace = 72,
75
+ Equal = 73,
76
+ BitwiseOr = 74,
77
+ GSRenderQueueType = 75,
78
+ GSBlendState = 76,
79
+ GSDepthState = 77,
80
+ GSStencilState = 78,
81
+ GSRasterState = 79,
82
+ GSEditorProperties = 80,
83
+ GSEditorMacros = 81,
84
+ GSEditor = 82,
85
+ GSTags = 83,
86
+ GSVertexShader = 84,
87
+ GSFragmentShader = 85,
88
+ GSSubShader = 86,
89
+ GSPass = 87,
90
+ GSBlendFactor = 88,
91
+ GSBlendOperation = 89,
92
+ GSBool = 90,
93
+ GSNumber = 91,
94
+ GSColor = 92,
95
+ GSCompareFunction = 93,
96
+ GSStencilOperation = 94,
97
+ GSCullMode = 95,
98
+ GSColorWriteMask = 96,
99
+ GSUsePass = 97,
100
+ MACRO_IF = 98,
101
+ MACRO_IFDEF = 99,
102
+ MACRO_IFNDEF = 100,
103
+ MACRO_ELSE = 101,
104
+ MACRO_ELIF = 102,
105
+ MACRO_ENDIF = 103,
106
+ MACRO_UNDEF = 104,
107
+ /** Legacy opaque `#define` token — whole directive packed into one lexeme. Retained
108
+ * for macros whose value can't be parsed as a GLSL expression (type aliases,
109
+ * qualifier aliases, partial-syntax macros). Expression-style macros instead emit
110
+ * `MACRO_DEFINE` + ID + value tokens + `MACRO_DEFINE_END`. */
111
+ MACRO_DEFINE_EXPRESSION = 105,
112
+ MACRO_CONDITIONAL_EXPRESSION = 106,
113
+ MACRO_CALL = 107,
114
+ /** `#define` directive head for expression-style macros. */
115
+ MACRO_DEFINE = 108,
116
+ /** Terminates a `MACRO_DEFINE` directive at end-of-line. */
117
+ MACRO_DEFINE_END = 109,
118
+ /** `(params)` block for a function-like `#define`. The lexer captures the entire
119
+ * parenthesized parameter list as one opaque token so the macro-define CFG rule
120
+ * doesn't need its own parameter-list production (which would conflict with
121
+ * function_call_parameter_list under LALR(1)). The AST consumer parses the
122
+ * lexeme to recover the individual parameter names. */
123
+ MACRO_DEFINE_PARAMS = 110
124
+ }
@@ -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 { ShaderCompiler } from "./ShaderCompiler";
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 };