Skip to content

Commit

Permalink
Implement lexing and parsing for all WGSL number literal types (#1184)
Browse files Browse the repository at this point in the history
* Implement lexing for all WGSL number literal types

* Move number literal test cases

* Adjust tests to match WGSL spec on number literals

Suffixes are not type names and currently only a plain `u` is supported
for uints. More specifically, `i` and `f` suffixes or suffixes with
widths in bits like `u32` are not supported at the moment.

* Add more tests for invalid number literal suffixes

* Replace code too new for Rust 1.43

* Implement parsing for hexadecimal integers

* Switch to enum number types, and Bytes for width

* Check for negative and leading zeros in int literals

* Implement parsing of hex floats with hexf-parse

* Update error message tests

* Update snapshot test output files

* Clean up lexer state machine code

* Clean up unexpected token error code

* Move number literal parsing to own submodule
  • Loading branch information
Hans Christian Schmitz authored Aug 24, 2021
1 parent 93db57c commit 58a5b7d
Show file tree
Hide file tree
Showing 26 changed files with 748 additions and 180 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ serde = { version = "1.0", features = ["derive"], optional = true }
petgraph = { version ="0.5", optional = true }
rose_tree = { version ="0.2", optional = true }
pp-rs = { version = "0.2.1", optional = true }
hexf-parse = { version = "0.2.1", optional = true }

[features]
default = []
Expand All @@ -40,7 +41,7 @@ serialize = ["serde"]
deserialize = ["serde"]
spv-in = ["petgraph", "spirv", "rose_tree"]
spv-out = ["spirv"]
wgsl-in = ["codespan-reporting"]
wgsl-in = ["codespan-reporting", "hexf-parse"]
wgsl-out = []
hlsl-out = []
span = ["codespan-reporting"]
Expand Down
Loading

0 comments on commit 58a5b7d

Please sign in to comment.