code wiki / (root) / nx_grep.nx

nx_grep.nx

buildroot/runtime/nx_grep.nx

2135 B39 linesdepth 3pulls 3 transitivereach 12 importersview sourcekind librarytopic grep
docsdependenciesstructsconstsfunctions

about

nx_grep.nx -- SOVEREIGN grep in NishiLang (operator: "we want nishi lang only not .sh... same with grep and other things you like to cheat with -- the nishi team should be all sovereign"). Replaces the shell `grep`: read a file, scan it line by line, print + count lines matching a pattern -- all bits-up over sys_read_file + substring search, no 3rd-party tool. This is the team owning text search over files, not shelling out. license_tier: ORIGINAL Reuses re_find (nx_research_extract).

dependencies 2 imports · 11 importers

nx_research_extract.nx nx_syscalls.nx nx_grep.nx nx_doc_census.nx nx_doc_census_real_audit_test.nx nx_doc_census_real_listing_test.nx nx_doc_census_run_test.nx nx_doc_census_test.nx nx_doc_inref.nx nx_doc_inref_test.nx nx_grep_test.nx nx_tool_census.nx nx_tool_census_run_test.nx

diagram shows first 10 each side; +0 more imports, +1 more importers in the complete lists below.

imports: nx_research_extract.nxnx_syscalls.nx

imported by: nx_doc_census.nxnx_doc_census_real_audit_test.nxnx_doc_census_real_listing_test.nxnx_doc_census_run_test.nxnx_doc_census_test.nxnx_doc_inref.nxnx_doc_inref_test.nxnx_grep_test.nxnx_tool_census.nxnx_tool_census_run_test.nxnx_tool_census_test.nx

structs

none

consts

none

functions

10func _gp_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
calls 1: sys_write
13func grep_line_matches(line: *u8, len: i64, needle: *u8) -> i64 { if re_find(line, len, needle) >= 0 { return 1 } return 0 }
called by 2: grep_filemain calls 1: re_find
16func grep_file(path: *u8, needle: *u8, print_matches: i64) -> i64
37func grep_count(path: *u8, needle: *u8) -> i64 { return grep_file(path, needle, 0) }
called by 1: main calls 1: grep_file
39func grep_has(path: *u8, needle: *u8) -> i64 { if grep_file(path, needle, 0) > 0 { return 1 } return 0 }
called by 1: main calls 1: grep_file