nx_eqparse_lib.nx
buildroot/runtime/nx_eqparse_lib.nx
about
nx_eqparse_lib.nx -- READ AN EQUATION A PERSON ACTUALLY TYPED, AND NORMALISE IT.
WHY THIS EXISTS (2026-09-03, and the operator is the reason). The /math surface shipped as a page whose
formulas were typeset at PUBLISH time and whose worked solutions were three hardcoded equations. The
operator's response was exact: "/math is just static output how does that match what i asked for". It
did not. A visitor could not type anything, and a page that demonstrates a capability is not the same
artifact as a page that PROVIDES it.
The solver existed (nx_calc_solve), the worked steps existed (nx_solve_steps_lib), the typesetter
existed (nx_mathml_lib). The missing rung between a human and all three was this: turning the text
"3x+4=19" into coefficients. That is the whole gap, and it is why the page could only ever be a brochure.
SCOPE, DECLARED: polynomials in a single variable x up to degree two, integer coefficients, both sides
of one equals sign, with implicit coefficients (x means 1x), unary signs, and ^2 for the square. It does
NOT do parentheses, division, other variables, or decimals. Anything outside that is REFUSED BY NAME so
a visitor is told what was not understood rather than handed a confident answer to a different question.
license_tier: ORIGINAL
dependencies 1 imports · 2 importers
imports: syscalls.nx
imported by: nx_eqparse_gate.nxnx_math_page.nx
structs
| none |
consts
| 21 | const EQ_OK: i64 = 0 |
| 22 | const EQ_ERR_EMPTY: i64 = 0 - 1 |
| 23 | const EQ_ERR_NO_EQUALS: i64 = 0 - 2 // no '=' at all: an expression is not an equation |
| 24 | const EQ_ERR_TWO_EQUALS: i64 = 0 - 3 |
| 25 | const EQ_ERR_BADCHAR: i64 = 0 - 4 // a character outside the declared scope |
| 26 | const EQ_ERR_DEGREE: i64 = 0 - 5 // a power above 2 |
| 27 | const EQ_ERR_NO_X: i64 = 0 - 6 // nothing to solve for |
| 28 | const EQ_MAXLEN: i64 = 512 |
| 31 | const EQ_MAX_COEF: i64 = 1000000 |
functions
| 33 | func eq_err_name(e: i64) -> *u8 called by 1: mp_render |
| 44 | func eq_is_digit(c: i64) -> i64 { if c >= 48 { if c <= 57 { return 1 } } return 0 } called by 1: eq_parse |
| 48 | func eq_parse(src: *u8, n: i64, out: *i64) -> i64 |