[wgsl] expect logical expressions, fix hex literals

This commit is contained in:
Dzmitry Malyshau
2020-03-05 21:14:58 -05:00
parent 330ce644d8
commit ee7882723a
3 changed files with 6 additions and 6 deletions

View File

@@ -1,6 +1,6 @@
# Naga
[![Matrix](https://img.shields.io/badge/Matrix-%23gfx%3Amatrix.org-blueviolet.svg)](https://matrix.to/#/#gfx:matrix.org)
[![Matrix](https://img.shields.io/badge/Matrix-%23naga%3Amatrix.org-blueviolet.svg)](https://matrix.to/#/#naga:matrix.org)
[![Crates.io](https://img.shields.io/crates/v/naga.svg?label=naga)](https://crates.io/crates/naga)
[![Docs.rs](https://docs.rs/naga/badge.svg)](https://docs.rs/naga)
[![Build Status](https://travis-ci.org/gfx-rs/naga.svg?branch=master)](https://travis-ci.org/gfx-rs/naga)

View File

@@ -121,8 +121,8 @@ scalar_type = {
| "u32"
}
return_statement = { "return" ~ primary_expression? }
assignment_statement = { ident ~ "=" ~ primary_expression }
return_statement = { "return" ~ logical_or_expression? }
assignment_statement = { ident ~ "=" ~ logical_or_expression }
statement = {
";"
@@ -179,8 +179,8 @@ typed_expression = { type_decl ~ "(" ~ argument_expression_list ~ ")" }
argument_expression_list = _{ (logical_or_expression ~ ",")* ~ logical_or_expression }
ident = @{ ASCII_ALPHA ~ (ASCII_ALPHANUMERIC | "_")* }
int_literal = @{ ("-"? ~ "0x"? ~ ASCII_HEX_DIGIT+) | "0" | ("-"? ~ ASCII_NONZERO_DIGIT ~ ASCII_DIGIT*) }
uint_literal = @{ ("0x"? ~ ASCII_HEX_DIGIT+) | "0" | (ASCII_NONZERO_DIGIT ~ ASCII_DIGIT*) }
int_literal = @{ ("-"? ~ "0x" ~ ASCII_HEX_DIGIT+) | "0" | ("-"? ~ ASCII_NONZERO_DIGIT ~ ASCII_DIGIT*) }
uint_literal = @{ ("0x" ~ ASCII_HEX_DIGIT+) | "0" | (ASCII_NONZERO_DIGIT ~ ASCII_DIGIT*) }
float_literal = @{ "-"? ~ ASCII_DIGIT+ ~ ("." ~ ASCII_DIGIT*)? }
bool_literal = @{ "true" | "false" }
string_literal = @{ "\"" ~ ( "\"\"" | (!"\"" ~ ANY) )* ~ "\"" }

View File

@@ -6,7 +6,7 @@ const c_scale: f32 = 1.2;
[[builtin position]] var<out> o_position : vec4<f32>;
fn main_vert() -> void {
o_position = vec4<f32>(scale * a_pos, 0.0, 1.0);
o_position = vec4<f32>(c_scale * a_pos, 0.0, 1.0);
return;
}
entry_point vertex as "main" = main_vert;