Skip to content

Commit

Permalink
Adding top level program type
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewRayCode committed Oct 5, 2024
1 parent 9d5ba4a commit 0385663
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,12 @@ and `#extension` have no effect, and can be fully preserved as part of parsing.
## Deviations from the Khronos Grammar
- The parser allows for programs to contain top level preprocessor statements,
like `#define X`, as a convenience to avoid preprocessing some programs, and
for simple programs lets you preserve preprocessor lines in the AST if you
want to do something specific with them. However, preprocessor statements at
any other part of the program are not allowed. The Khronos grammar does not
include preprocessor statements.
- `selection_statement` is renamed to `if_statement`
- The grammar specifies `declaration` itself ends with a semicolon. I moved the
semicolon into the `declaration_statement` rule.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"engines": {
"node": ">=16"
},
"version": "5.2.0",
"version": "5.3.0",
"type": "module",
"description": "A GLSL ES 1.0 and 3.0 parser and preprocessor that can preserve whitespace and comments",
"scripts": {
Expand Down
8 changes: 7 additions & 1 deletion src/ast/ast-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@

import { Scope } from '../parser/scope.js';

// Valid top level program lines
export type ProgramStatement =
| PreprocessorNode
| DeclarationStatementNode
| FunctionNode;

// The overall result of parsing, which incldues the AST and scopes
export interface Program {
type: 'program';
program: (PreprocessorNode | DeclarationStatementNode | FunctionNode)[];
program: ProgramStatement[];
scopes: Scope[];
wsStart?: string;
wsEnd?: string;
Expand Down

0 comments on commit 0385663

Please sign in to comment.