From e0bf13622b0922252439e3fa8b43df9877678d75 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Sun, 25 Oct 2026 02:39:11 +0100 Subject: numbers are separate parser states and there are syntactic octal and hexadecimal constants now * Instead of every digit being a stack-modifying standalone command, there is a single continuous parser state (teco_state_number) now - even though it has certain unique characteristics. They are consequently documented in the ARITHMETICS AND EXPRESSIONS chapter of sciteco(7). * A number will therefore be rubbed out entirely by CTRL+W, including a possible @-modifier. * (!) Spaces within constants are no longer ignored, but will push separate numbers to the stack instead (`1 2 3` pushes 3 numbers). The significance of the `,` operator is thus further reduced. * (!) You can no longer "append" to numbers on the stack as in `Qa001` - this was never actually used and caused more confusion. * (!) Digits outside the current radix are no longer accepted. E.g. digit 2 after `2^R`. This feature was also never used. * (!) Octal constants are supported with leading zeros as in C. This works regardless of the current radix set via `8^R` or `^O`. It remains to see whether this is actually useful or is rather annoying (since every constant beginning with 0 is automatically octal, you cannot left-pad arbitrary numbers with 0). * Hexadecimal constants are supported by at-modifying them as in `@0ff`. They must still begin with a digit 0-9 and since A-F are valid SciTECO commands, you may need additional spaces to separate hexadecimal constants from regular commands as in `@0ff D`. During syntax highlighting the number style is extended back to the at-sign. Note: Hexadecimal constants couldn't have been realized via `16^R` (or some shortcut) since that depends on runtime state, but we must know during parsing whether symbols A-F are part of the number of regular SciTECO commands. * The new hexadecimal constants are used in the color schemes now. Thanks to them, we no longer need workarounds like the "color.rgb" macro. * Since numbers don't have a dedicated terminator character, but any letter may terminate it, the number state must behave similar to a start state. Consequently, hexadecimal constants will currently be auto-case-folded if you enabled this feature. I recommend not to write hex constants in upper-case, though. Perhaps this should be worked around with a custom process_edit_cmd() callback. * Test suite updated --- TODO | 33 +++++---------------------------- 1 file changed, 5 insertions(+), 28 deletions(-) (limited to 'TODO') diff --git a/TODO b/TODO index 514ad4f..6c7f0f6 100644 --- a/TODO +++ b/TODO @@ -274,30 +274,11 @@ Features: be disabled in parser-terminator-mode). Q-Reg specs should support alternative balanced escapes as well for symmetry. - * Numbers could be separate states instead of stack operating - commands. The current behaviour has few benefits. - If a number is a regular command that stops parsing at the - first invalid character in the current radix, we could write - hexadcimal constants like 16^R0BEEF^D (still clumsy...). - On the other hand, the radix is runtime state and parsing - must not depend on runtime state in SciTECO to ensure - parseability of the language. - We could use the @ modifier though, so a hexadecimal constant - must always begin with @0-@9. - @1e\ would be enough to insert the escape character. - If the number starts with a non-decimal digit, you will have to - prefix it with 0, as in @0FF. If it is followed by a command A-F, - you can add an additional space or even brace the expression as in - `@0FF A` or `(@0FF)A`. - The same could be done with a caret: `^0FF`. - Alternatively, ^P would still be available as a single-key-press - hex-constant prefix. - Octal constants could begin with 0 as in C, e.g. 0666 - * Furthermore, this opens the possibility of floating point - numbers. The "." command does not take arguments, so it - could be part of the number syntax. This disallows constructs - like "23." to push 23 and Dot which have to be replaced by - "23,.". + * Floating point numbers constants. + The "." command does not take arguments, so it + could be part of the number syntax. This disallows constructs + like "23." to push 23 and Dot which have to be replaced by + "23,.". * In the most simple case, all TECO numbers could be floats/doubles with division/modulo having integer semantics. A separate floating point division operator could be introduced @@ -307,11 +288,7 @@ Features: The operator decides how to interpret the arguments and the return type. This is good since we'd need less operators and it's good to keep true integers around. - * Having a separate number parser state will slightly simplify - number syntax highlighting (see teco_lexer_getstyle()). * The first application of floats could be for U[lexer.font]. - * ^H as shortcut for 16^R. ^H is backspace, but it won't be - necessary to type very often. * Key macro masking flag for the beginning of the command line. May be useful e.g. for solarized's F5 key (i.e. function key macros that need to terminate the command line as they -- cgit v1.2.3