Skip to content

Commit

Permalink
Switch to enum number types, and Bytes for width
Browse files Browse the repository at this point in the history
  • Loading branch information
Hans Christian Schmitz committed Aug 20, 2021
1 parent 7bb40f6 commit 0355553
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 82 deletions.
30 changes: 15 additions & 15 deletions src/front/wgsl/lexer.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::{conv, Error, ExpectedToken, Span, Token, TokenSpan};
use super::{conv, Error, ExpectedToken, NumberType, Span, Token, TokenSpan};

fn _consume_str<'a>(input: &'a str, what: &str) -> Option<&'a str> {
if input.starts_with(what) {
Expand Down Expand Up @@ -303,13 +303,13 @@ fn consume_number(input: &str) -> (Token, &str) {
value
},
ty: if state.uint_suffix {
'u'
NumberType::Uint
} else if state.is_float() {
'f'
NumberType::Float
} else {
'i'
NumberType::Sint
},
width: "",
width: None,
},
rest,
)
Expand Down Expand Up @@ -639,8 +639,8 @@ fn test_tokens() {
&[
Token::Number {
value: "92",
ty: 'i',
width: "",
ty: NumberType::Sint,
width: None,
},
Token::Word("No"),
],
Expand All @@ -650,13 +650,13 @@ fn test_tokens() {
&[
Token::Number {
value: "2",
ty: 'u',
width: "",
ty: NumberType::Uint,
width: None,
},
Token::Number {
value: "3",
ty: 'i',
width: "",
ty: NumberType::Sint,
width: None,
},
Token::Word("o"),
],
Expand All @@ -666,8 +666,8 @@ fn test_tokens() {
&[
Token::Number {
value: "2.4",
ty: 'f',
width: "",
ty: NumberType::Float,
width: None,
},
Token::Word("f44po"),
],
Expand All @@ -691,8 +691,8 @@ fn test_variable_decl() {
Token::Paren('('),
Token::Number {
value: "0",
ty: 'i',
width: "",
ty: NumberType::Sint,
width: None,
},
Token::Paren(')'),
Token::DoubleParen(']'),
Expand Down
Loading

0 comments on commit 0355553

Please sign in to comment.