Skip to content

Commit 184b7c6

Browse files
committed
[assembler] Support super/subscript identical-to sign (≡).
1 parent b513d2f commit 184b7c6

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

assembler/src/asmlib/lexer.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ pub(crate) enum Token {
114114

115115
Pipe(Script),
116116
ProperSuperset,
117-
IdenticalTo,
117+
IdenticalTo(Script),
118118
Tilde(Script),
119119
LessThan,
120120
GreaterThan,
@@ -185,7 +185,7 @@ impl Display for Token {
185185
Token::Equals(script) => write_elevated(script, "="),
186186
Token::Pipe(script) => write_elevated(script, "|"),
187187
Token::ProperSuperset => f.write_char('⊃'),
188-
Token::IdenticalTo => f.write_char('≡'),
188+
Token::IdenticalTo(script) => write_elevated(script, "≡"),
189189
Token::Tilde(script) => write_elevated(script, "~"),
190190
Token::LessThan => f.write_char('<'),
191191
Token::GreaterThan => f.write_char('>'),
@@ -535,7 +535,7 @@ mod lexer_impl_new {
535535
GlyphShape::Tilde => Some(Token::Tilde(script)),
536536
GlyphShape::LeftBrace => only_normal(Token::LeftBrace),
537537
GlyphShape::RightBrace => only_normal(Token::RightBrace),
538-
GlyphShape::IdenticalTo => only_normal(Token::IdenticalTo),
538+
GlyphShape::IdenticalTo => Some(Token::IdenticalTo(script)),
539539
GlyphShape::Equals => Some(Token::Equals(script)),
540540
GlyphShape::Apostrophe => make_symex(),
541541
GlyphShape::Asterisk => only_normal(Token::Asterisk),

assembler/src/asmlib/lexer/tests.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -936,8 +936,20 @@ fn test_proper_superset() {
936936

937937
#[test]
938938
fn test_identical_to() {
939-
assert_eq!(scan_tokens_only("≡"), Ok(vec![Token::IdenticalTo,]));
940-
assert_eq!(scan_tokens_only("@hamb@"), Ok(vec![Token::IdenticalTo,]));
939+
use Script::*;
940+
assert_eq!(scan_tokens_only("≡"), Ok(vec![Token::IdenticalTo(Normal),]));
941+
assert_eq!(
942+
scan_tokens_only("@hamb@"),
943+
Ok(vec![Token::IdenticalTo(Normal),])
944+
);
945+
assert_eq!(
946+
scan_tokens_only("@sup_hamb@"),
947+
Ok(vec![Token::IdenticalTo(Super),])
948+
);
949+
assert_eq!(
950+
scan_tokens_only("@sub_hamb@"),
951+
Ok(vec![Token::IdenticalTo(Sub),])
952+
);
941953
}
942954

943955
#[test]

assembler/src/asmlib/parser.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ where
316316
just(Tok::Arrow(Script::Normal)).to('→'),
317317
just(Tok::Pipe(Script::Normal)).to('|'),
318318
just(Tok::ProperSuperset).to('⊃'),
319-
just(Tok::IdenticalTo).to('≡'),
319+
just(Tok::IdenticalTo(Script::Normal)).to('≡'),
320320
just(Tok::Tilde(Script::Normal)).to('~'),
321321
just(Tok::LessThan).to('<'),
322322
just(Tok::GreaterThan).to('>'),
@@ -327,6 +327,7 @@ where
327327
just(Tok::LogicalOr(Script::Normal)).to('∨'),
328328
just(Tok::LogicalAnd(Script::Normal)).to('∧'),
329329
))
330+
.labelled("macro terminator")
330331
}
331332

332333
fn macro_argument<'a, I>() -> impl Parser<'a, I, MacroArgument, Extra<'a>>

0 commit comments

Comments
 (0)