operator grapheme tree #4

Open
opened 2026-08-07 07:18:17 +00:00 by jaynuine · 2 comments
Owner

store operator graphemes in a diff tree, where only differing string subsections are stored, with root to leaf verticality encoding left to right order, and horizontality mapping to a greater than relation between strings (bucket comparison)

so to traverse the tree test for issubstr{operator, token} to descend, and since all strings of a layer are comparable by >, subsequent tests should be optimised by only considering strings still in range after each comparison (chaudfroid)

  • a
  • b
    • a
    • d
    • k
    • v
  • m
  • w
  • x

token := "bd"

we need not test for unnecessary possibilities ; beginning at the root layer, the character b is between a and x, so we pick a value near the middle of our interval (just pick one of the middle two on even lengths) and the result of comparing the current character (b) to the chosen middle (let's say m) will inform us of which slice of the layer may hold an exact match ;
since b < m, we will be interested in the left half ; so we redefine our search bracket to this interval, and repeat until a match is found, or none is ; assuming the former, we may plunge one level deeper, and continue matching from there, offsetting the token of course by the length of the previously matched segment

store operator graphemes in a diff tree, where only differing string subsections are stored, with root to leaf verticality encoding left to right order, and horizontality mapping to a greater than relation between strings (bucket comparison) so to traverse the tree test for issubstr{operator, token} to descend, and since all strings of a layer are comparable by `>`, subsequent tests should be optimised by only considering strings still in range after each comparison (chaudfroid) - a - b - a - d - k - v - m - w - x token := "bd" we need not test for unnecessary possibilities ; beginning at the root layer, the character `b` is between `a` and `x`, so we pick a value near the middle of our interval (just pick one of the middle two on even lengths) and the result of comparing the current character (`b`) to the chosen middle (let's say `m`) will inform us of which slice of the layer may hold an exact match ; since `b < m`, we will be interested in the left half ; so we redefine our search bracket to this interval, and repeat until a match is found, or none is ; assuming the former, we may plunge one level deeper, and continue matching from there, offsetting the token of course by the length of the previously matched segment
jaynuine added this to the todo project 2026-08-07 07:18:17 +00:00
Author
Owner

this may be overkill for the few operators we have
> < >> << |
and i guess $ could be implemented as one since this would allow precedence ?

this may be overkill for the few operators we have `>` `<` `>>` `<<` `|` and i guess `$` could be implemented as one since this would allow precedence ?
Author
Owner

yea this is overkill let's just implement this naively

yea this is overkill let's just implement this naively
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
jaynuine/minishell#4
No description provided.