pretty arrow

This commit is contained in:
nora 2022-06-26 12:00:30 +02:00
parent 56974cf077
commit 91f4b397a2
2 changed files with 41 additions and 0 deletions

View file

@ -349,6 +349,8 @@ where
(b'.', Some(b'.'), Some(b'.')) => triple_punct!(self, DotDotDot), (b'.', Some(b'.'), Some(b'.')) => triple_punct!(self, DotDotDot),
(b'<', Some(b'<'), Some(b'=')) => triple_punct!(self, LeftLeftChevronEq), (b'<', Some(b'<'), Some(b'=')) => triple_punct!(self, LeftLeftChevronEq),
(b'>', Some(b'>'), Some(b'=')) => triple_punct!(self, RightRightChevronEq), (b'>', Some(b'>'), Some(b'=')) => triple_punct!(self, RightRightChevronEq),
// the pretty pretty unicode arrow → is obviously supported here, i hope this won't cause probelms
(b'\xE2', Some(b'\x86'), Some(b'\x92')) => triple_punct!(self, Arrow),
// DOUBLE CHARACTER PUNCTUATION // DOUBLE CHARACTER PUNCTUATION
(b'<', Some(b':'), _) => double_punct!(self, BracketOpen), (b'<', Some(b':'), _) => double_punct!(self, BracketOpen),
(b':', Some(b'>'), _) => double_punct!(self, BracketClose), (b':', Some(b'>'), _) => double_punct!(self, BracketClose),
@ -457,4 +459,13 @@ int hello(const char* uwu) <%
lex_test!(src); lex_test!(src);
} }
#[test]
fn pretty_arrow() {
let src = r#"
struct_ptrfield;
"#;
lex_test!(src);
}
} }

View file

@ -0,0 +1,30 @@
---
source: parser/src/pre/lexer.rs
expression: tokens
---
[
(
Identifier(
"struct_ptr",
),
1..11,
),
(
Punctuator(
Arrow,
),
11..14,
),
(
Identifier(
"field",
),
14..19,
),
(
Punctuator(
Semicolon,
),
19..20,
),
]