File tree Expand file tree Collapse file tree 3 files changed +5
-6
lines changed Expand file tree Collapse file tree 3 files changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -118,5 +118,5 @@ export interface GenerateOptions {
118
118
* Generates a string of GLSL (WGSL WIP) code from an [AST](https://en.wikipedia.org/wiki/Abstract_syntax_tree).
119
119
*/
120
120
export function generate ( program : Program , options : GenerateOptions ) : string {
121
- return '#version 300 es\n' + format ( program ) . replaceAll ( '\n\n' , '\n' )
121
+ return format ( program ) . replaceAll ( '\n\n' , '\n' ) . trim ( )
122
122
}
Original file line number Diff line number Diff line change @@ -579,7 +579,10 @@ function parsePreprocessor(tokens: Token[]): PreprocessorStatement {
579
579
value = [ { type : 'Identifier' , name : consume ( tokens ) . value } ]
580
580
consume ( tokens , '>' )
581
581
} else if ( name !== 'else' && name !== 'endif' ) {
582
- value = [ parseExpression ( tokens ) ]
582
+ value = [ ]
583
+ while ( tokens . length && tokens [ 0 ] . value !== '\\' ) {
584
+ value . push ( parseExpression ( tokens ) )
585
+ }
583
586
}
584
587
}
585
588
@@ -641,9 +644,6 @@ const DIRECTIVE_REGEX = /(^\s*#[^\\]*?)(\n|\/[\/\*])/gm
641
644
* Parses a string of GLSL (WGSL WIP) code into an [AST](https://en.wikipedia.org/wiki/Abstract_syntax_tree).
642
645
*/
643
646
export function parse ( code : string ) : Program {
644
- // Remove (implicit) version header
645
- code = code . replace ( '#version 300 es' , '' )
646
-
647
647
// Fold newlines
648
648
code = code . replace ( NEWLINE_REGEX , '' )
649
649
Original file line number Diff line number Diff line change @@ -40,7 +40,6 @@ const glsl = /* glsl */ `#version 300 es
40
40
float one, two;
41
41
} globals;
42
42
43
-
44
43
// struct X {
45
44
// #if !defined(BLA)
46
45
// int y;
You can’t perform that action at this time.
0 commit comments