Skip to content

Commit

Permalink
Allow for preprocessor as a statement
Browse files Browse the repository at this point in the history
  • Loading branch information
unjello committed Jul 12, 2021
1 parent 188829a commit 69fda79
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions glsl/src/parsers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1305,6 +1305,7 @@ pub fn multiplicative_expr(i: &str) -> ParserResult<syntax::Expr> {
/// Parse a simple statement.
pub fn simple_statement(i: &str) -> ParserResult<syntax::SimpleStatement> {
alt((
map(preprocessor, syntax::SimpleStatement::Preprocessor),
map(jump_statement, syntax::SimpleStatement::Jump),
map(iteration_statement, syntax::SimpleStatement::Iteration),
map(case_label, syntax::SimpleStatement::CaseLabel),
Expand Down
1 change: 1 addition & 0 deletions glsl/src/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,7 @@ impl Statement {
/// Simple statement.
#[derive(Clone, Debug, PartialEq)]
pub enum SimpleStatement {
Preprocessor(Preprocessor),
Declaration(Declaration),
Expression(ExprStatement),
Selection(SelectionStatement),
Expand Down
1 change: 1 addition & 0 deletions glsl/src/transpiler/glsl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1343,6 +1343,7 @@ where
F: Write,
{
match *sst {
syntax::SimpleStatement::Preprocessor(ref pp) => show_preprocessor(f, pp),
syntax::SimpleStatement::Declaration(ref d) => show_declaration(f, d),
syntax::SimpleStatement::Expression(ref e) => show_expression_statement(f, e),
syntax::SimpleStatement::Selection(ref s) => show_selection_statement(f, s),
Expand Down
1 change: 1 addition & 0 deletions glsl/src/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1199,6 +1199,7 @@ macro_rules! make_host_trait {

if visit == Visit::Children {
match self {
syntax::SimpleStatement::Preprocessor(p) => p.$mthd_name(visitor),
syntax::SimpleStatement::Declaration(d) => d.$mthd_name(visitor),
syntax::SimpleStatement::Expression(e) => e.$mthd_name(visitor),
syntax::SimpleStatement::Selection(s) => s.$mthd_name(visitor),
Expand Down

0 comments on commit 69fda79

Please sign in to comment.