code wiki / (root) / nx_grep_rt.nx

nx_grep_rt.nx

buildroot/runtime/nx_grep_rt.nx

6518 B167 linesdepth 6pulls 6 transitivereach 12 importersview sourcekind librarytopic grep
docsdependenciesstructsconstsfunctions

about

nx_grep.nx -- S1 first stone of NISHI_SHELL_REPLACEMENT_ROADMAP.md. Canonical: this is the substrate-wide canonical grep primitive per [[feedback-bits-up-shell-replace-linux-brother-tools]]. Substring + line-number reporting over a byte buffer. Composes nx_str_find from nx_string_ops.nx; no Linux-brother grep / ripgrep dependency. Bits-up doctrine applied to the shell tier: substrate's audit / tooling layer stops depending on grep. S2 will add regex (RE2- style DFA + NFA hybrid). S2.5+ will add SIMD substring (Muła- Lemire 2020), Aho-Corasick multi-pattern (1975), and tournament- based variant selection per-die via ETG. API: nx_grep_count(buf, n_buf, pattern, n_pat) -> total occurrences of pattern in buf (overlapping matches NOT counted; substring search advances past each match) nx_grep_first_offset(buf, n_buf, pattern, n_pat) -> byte offset of first occurrence, -1 if none nx_grep_lines_match_count(buf, n_buf, pattern, n_pat) -> count of DISTINCT lines containing at least one match (a line with N occurrences counts as 1) nx_grep_first_line_number(buf, n_buf, pattern, n_pat) -> 1-based line number of the first matching line, -1 if none nx_grep_any(buf, n_buf, pattern, n_pat) -> 1 if pattern occurs at least once, 0 otherwise Composes: [[NISHI_SHELL_REPLACEMENT_ROADMAP]] S1 (this is the first stone) nx_string_ops.nx (nx_str_find substring search; SHIPPED) [[feedback-bits-up-shell-replace-linux-brother-tools]] (cardinal) [[feedback-bits-up-exceed-never-match]] (research absorbed + substrate exceeds; cannot exceed grep by cloning grep) [[feedback-no-tool-proliferation-bit-level]] (nx_grep is the canonical; future grep-adjacent primitives compose this)

dependencies 2 imports · 5 importers

nx_syscalls.nx nx_string_ops.nx nx_grep_rt.nx nx_doc_census.nx nx_doc_census_test.nx nx_doc_inref.nx nx_shelltool.nx nx_tool_census.nx

imports: nx_syscalls.nxnx_string_ops.nx

imported by: nx_doc_census.nxnx_doc_census_test.nxnx_doc_inref.nxnx_shelltool.nxnx_tool_census.nx

structs

none

consts

none

functions

76func nx_grep_count(buf: *u8, n_buf: nx_int, pattern: *u8, n_pat: nx_int) -> nx_int
calls 1: nx_str_find
97func nx_grep_first_offset(buf: *u8, n_buf: nx_int, pattern: *u8, n_pat: nx_int) -> nx_int
105func nx_grep_any(buf: *u8, n_buf: nx_int, pattern: *u8, n_pat: nx_int) -> nx_int
117func _grep_line_number_at_offset(buf: *u8, off: nx_int) -> nx_int
130func nx_grep_first_line_number(buf: *u8, n_buf: nx_int, pattern: *u8, n_pat: nx_int) -> nx_int
145func nx_grep_lines_match_count(buf: *u8, n_buf: nx_int, pattern: *u8, n_pat: nx_int) -> nx_int