Skip to content

Commit fc24b53

Browse files
committed
[assembler] Accept U+2024 as a subscript dot.
It would be too confusing to accept ASCII "." as a subscript character.
1 parent 9b2b222 commit fc24b53

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

assembler/src/asmlib/driver/tests.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -668,12 +668,11 @@ fn default_assigned_index_register_easy_case() {
668668

669669
#[test]
670670
fn test_bit_designator_evaluation_result() {
671-
let program = assemble_source("100|SKM@sub_2@@sub_dot@@sub_1@ 0\n", Default::default())
672-
.expect("program is valid");
671+
let program = assemble_source("100|SKM₂․₁ 0\n", Default::default()).expect("program is valid");
673672
dbg!(&program);
674673
assert_eq!(program.chunks.len(), 1);
675674
assert_eq!(program.chunks[0].words.len(), 1);
676-
// SKM is opcode 0o17. bit designator 2.1 is 0o41. The opcode
675+
// SKM is opcode 0o17. bit designator 2·1 is 0o41. The opcode
677676
// gets shifted left 24 bit positions, the index valis is shiifted
678677
// left by 18 bit positions.
679678
assert_eq!(program.chunks[0].words[0], u36!(0o001_741_000_000));

assembler/src/asmlib/glyph.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,13 @@ const ALL_GLYPHS: &[Glyph] = &[
843843
// This is a centre dot, not a period. We use a centre dot so
844844
// that it's not confused with a subscript dot.
845845
normal: Some('\u{00B7}'), // ·
846-
subscript: None,
846+
847+
// Using an ASCII full stop / period (".") would be too
848+
// confusing for the user, who (when preparing source code
849+
// input) might expect this to be interpreted as the
850+
// normal-script PERIOD. So for subscript we instead use
851+
// U+2024, "One Dot Leader".
852+
subscript: Some('\u{2024}'), // "․" (not ASCII ".")
847853
superscript: None,
848854
..GDEF
849855
},

assembler/src/asmlib/parser/tests.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,10 @@ fn test_subscript_literal_oct_decmode() {
235235
parse_successfully_with("₃₁@sub_dot@", literal(Script::Sub), set_decimal_mode),
236236
LiteralValue::from((span(0..15), Script::Sub, Unsigned36Bit::from(0o31_u32),))
237237
);
238+
assert_eq!(
239+
parse_successfully_with("₃₁․", literal(Script::Sub), set_decimal_mode),
240+
LiteralValue::from((span(0..9), Script::Sub, Unsigned36Bit::from(0o31_u32),))
241+
);
238242
}
239243

240244
#[test]

0 commit comments

Comments
 (0)