diff options
| author | Robin Haberkorn <rhaberkorn@fmsbw.de> | 2026-10-31 13:46:11 +0100 |
|---|---|---|
| committer | Robin Haberkorn <rhaberkorn@fmsbw.de> | 2026-10-31 21:13:19 +0100 |
| commit | 4aa2b717f9e050783b567540d9bb0193d692e3e9 (patch) | |
| tree | 39b3734c464655e6d1c21390945209a66f952654 /src/search.c | |
| parent | e0bf13622b0922252439e3fa8b43df9877678d75 (diff) | |
support floating point numbers
* Extends the SciTECO type system. A number on the expression stack
or in a Q-register can be either an integer or a float.
* Floating point constants begin with a digit (like all other
numbers), are followed by a `.` and an optional fractional part.
Exponents cannot currently be written.
E.g. `1.` == `1.0`. But `.0` would still be `.,0`.
(!) To push an integer followed by dot, you must now write e.g. `1,.` or `1 .`.
* All of the basic arithmetic operators operate like this:
If both operands are integers, the result is also an integer (integer arithmetics).
If at least one of the operands is a float, the result is also a float (float arithmetics).
* All of the binary operators (AND, OR, XOR) always cast all
operands to integer and the result is always an integer as well.
* You can "cast" integers to float by `*1.` or `/1.`.
You can "cast" floats to integers using `#0`.
* Most commands still accept only integers. Floats are implicitly casted to integers.
Float-aware commands are: =, \, ^W, Qq, Uq, %q and the conditionals.
* `%q` will not change the current type of register q.
* Numeric part of "lexer.font" is now a float (in points).
* You cannot currently print octal and hexadecimal floats.
`==` and `===` are identical to `=` on floats.
* `===` is now printing hex integers in lower case.
This is because SciTECO's coding style for hex constants is also lower case.
* `--with-teco-integer` renamed to `--with-teco-number`.
Diffstat (limited to 'src/search.c')
| -rw-r--r-- | src/search.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/search.c b/src/search.c index 31a551e..0b59db5 100644 --- a/src/search.c +++ b/src/search.c @@ -102,12 +102,12 @@ teco_state_control_search_mode(teco_machine_main_t *ctx, GError **error) teco_bool_t search_mode; if (!teco_expressions_args() && teco_num_sign > 0) { - if (!reg->vtable->get_integer(reg, &search_mode, error)) + if (!teco_qreg_get_integer(reg, &search_mode, error)) return; teco_expressions_push(search_mode); } else { - if (!teco_expressions_pop_num_calc(&search_mode, teco_num_sign, error) || - !reg->vtable->set_integer(reg, search_mode, error)) + if (!teco_expressions_pop_int_calc(&search_mode, teco_num_sign, error) || + !teco_qreg_set_integer(reg, search_mode, error)) return; } } @@ -126,11 +126,11 @@ teco_state_search_initial(teco_machine_main_t *ctx, GError **error) teco_search_parameters.pos = teco_interface_ssm(SCI_GETCURRENTPOS, 0, 0); teco_int_t v1, v2; - if (!teco_expressions_pop_num_calc(&v2, teco_num_sign, error)) + if (!teco_expressions_pop_int_calc(&v2, teco_num_sign, error)) return FALSE; if (teco_expressions_args()) { /* TODO: optional count argument? */ - v1 = teco_expressions_pop_num(0); + v1 = teco_expressions_pop_int(0); if (v1 <= v2) { teco_search_parameters.count = 1; teco_search_parameters.from = teco_interface_glyphs2bytes_absdot(v1); @@ -969,7 +969,7 @@ teco_state_search_process(teco_machine_main_t *ctx, teco_string_t str, gsize new teco_qreg_t *search_reg = teco_qreg_table_find(&teco_qreg_table_globals, "_", 1); g_assert(search_reg != NULL); - if (!search_reg->vtable->set_integer(search_reg, TECO_FAILURE, error)) + if (!teco_qreg_set_integer(search_reg, TECO_FAILURE, error)) return FALSE; g_autoptr(teco_machine_qregspec_t) qreg_machine; @@ -1063,7 +1063,7 @@ teco_state_search_process(teco_machine_main_t *ctx, teco_string_t str, gsize new teco_ring_current = buffer; } - if (!search_reg->vtable->set_integer(search_reg, teco_bool(!count), error)) + if (!teco_qreg_set_integer(search_reg, teco_bool(!count), error)) return FALSE; if (!count) @@ -1105,7 +1105,7 @@ teco_state_search_done(teco_machine_main_t *ctx, teco_string_t str, GError **err } teco_int_t search_state; - if (!search_reg->vtable->get_integer(search_reg, &search_state, error)) + if (!teco_qreg_get_integer(search_reg, &search_state, error)) return FALSE; if (teco_machine_main_eval_colon(ctx) > 0) @@ -1221,11 +1221,11 @@ teco_state_search_all_initial(teco_machine_main_t *ctx, GError **error) teco_int_t v1, v2; - if (!teco_expressions_pop_num_calc(&v2, teco_num_sign, error)) + if (!teco_expressions_pop_int_calc(&v2, teco_num_sign, error)) return FALSE; if (teco_expressions_args()) { /* TODO: optional count argument? */ - v1 = teco_expressions_pop_num(0); + v1 = teco_expressions_pop_int(0); if (v1 <= v2) { teco_search_parameters.count = 1; teco_search_parameters.from_buffer = teco_ring_find(v1); |
