summary refs log tree commit diff
diff options
context:
space:
mode:
authorIrene Knapp <ireneista@irenes.space>2024-10-07 23:31:20 -0700
committerIrene Knapp <ireneista@irenes.space>2024-10-07 23:31:20 -0700
commit381f71833ebfb99a7dde16b6f3ceeb4c0fd5a8bd (patch)
tree647ce7ce6159d2548df0d6b77019d6725e975b2b
parent973332361a44503a6e70eeafae05d853ff15ec26 (diff)
implement leading decimal point for number input
Force-Push: yeah my CI is broken
Change-Id: Ic710549c437954e88516ebe9698459353571a011
-rw-r--r--src/main.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
index 8ecb03e..a94feaa 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -13,6 +13,7 @@ mod tests;
 const HELP_TEXT: &str =
     "LITERALS\n\
      0-9     integers\n\
+     .       decimal point\n\
      _       toggle sign (or, as a command, negate the top item on the stack)\n\
      [...]   string\n\
      (...)   named command (see below)\n\
@@ -292,6 +293,14 @@ fn make_command_character_readtable() -> ReadTable {
     Ok(())
   });
 
+  result.set_action('.', move |_, state| {
+    state.mode = Mode::Decimal;
+    state.num = dec!(0);
+    state.decimal_offset = dec!(1);
+
+    Ok(())
+  });
+
   result.set_action('_', move |_, state| {
     state.mode = Mode::Integer;
     state.num = dec!(0);