Skip to content

Commit 69fda79

Browse files
committedJul 12, 2021
Allow for preprocessor as a statement
Closes hadronized#64. Closes hadronized#117.
1 parent 188829a commit 69fda79

File tree

4 files changed

+4
-0
lines changed

4 files changed

+4
-0
lines changed
 

‎glsl/src/parsers.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1305,6 +1305,7 @@ pub fn multiplicative_expr(i: &str) -> ParserResult<syntax::Expr> {
13051305
/// Parse a simple statement.
13061306
pub fn simple_statement(i: &str) -> ParserResult<syntax::SimpleStatement> {
13071307
alt((
1308+
map(preprocessor, syntax::SimpleStatement::Preprocessor),
13081309
map(jump_statement, syntax::SimpleStatement::Jump),
13091310
map(iteration_statement, syntax::SimpleStatement::Iteration),
13101311
map(case_label, syntax::SimpleStatement::CaseLabel),

‎glsl/src/syntax.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,7 @@ impl Statement {
10111011
/// Simple statement.
10121012
#[derive(Clone, Debug, PartialEq)]
10131013
pub enum SimpleStatement {
1014+
Preprocessor(Preprocessor),
10141015
Declaration(Declaration),
10151016
Expression(ExprStatement),
10161017
Selection(SelectionStatement),

‎glsl/src/transpiler/glsl.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1343,6 +1343,7 @@ where
13431343
F: Write,
13441344
{
13451345
match *sst {
1346+
syntax::SimpleStatement::Preprocessor(ref pp) => show_preprocessor(f, pp),
13461347
syntax::SimpleStatement::Declaration(ref d) => show_declaration(f, d),
13471348
syntax::SimpleStatement::Expression(ref e) => show_expression_statement(f, e),
13481349
syntax::SimpleStatement::Selection(ref s) => show_selection_statement(f, s),

‎glsl/src/visitor.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1199,6 +1199,7 @@ macro_rules! make_host_trait {
11991199

12001200
if visit == Visit::Children {
12011201
match self {
1202+
syntax::SimpleStatement::Preprocessor(p) => p.$mthd_name(visitor),
12021203
syntax::SimpleStatement::Declaration(d) => d.$mthd_name(visitor),
12031204
syntax::SimpleStatement::Expression(e) => e.$mthd_name(visitor),
12041205
syntax::SimpleStatement::Selection(s) => s.$mthd_name(visitor),

0 commit comments

Comments
 (0)