code wiki / (root) / nx_css_tokenize.nx

nx_css_tokenize.nx

buildroot/runtime/nx_css_tokenize.nx

16746 B499 linesdepth 2pulls 2 transitivereach 104 importersview sourcekind librarytopic css
docsdependenciesstructsconstsfunctions

about

nx_css_tokenize.nx -- CSS tokenizer for the Nishi browser. Phase 2 (CSS subset) of docs/NISHI_BROWSER_ROADMAP.md. Recognises the subset andelinwest.com + ide.html + most modern hand-written CSS uses: tag selectors `body`, `div`, `h1` class selectors `.head`, `.menu-item` id selectors `#main`, `#sidebar` descendant combinator (whitespace between simple selectors) property:value `color: red`, `font-size: 16px` hex colors `#ff0000`, `#fff` number+unit `16px`, `1.5em`, `100%` quoted strings `"Arial"`, `'sans-serif'` block delimiters `{ ... }` statement separator `;` selector list `,` between selectors What it does NOT handle yet (named Phase 2b improvements): - @-rules (@media, @keyframes, @import, @font-face) - pseudo-classes (:hover, :nth-child) - pseudo-elements (::before, ::after) - attribute selectors ([href^="https"]) - sibling/child combinators (+ ~ >) - calc() / var() / CSS variables - URL functions - escape sequences inside identifiers - block comments / and / asterisk Subset is sufficient for Phase 2 demo: parse a sovereign-served stylesheet, build a selector -> declarations map, apply to the DOM tree from nx_html_tokenizer. Per cardinal `feedback-honest-perf-verdict-no-aspirational-claims`: gap list is EXACT and lives in this header. genealogy_id: w3c_css_syntax_module_level_3 + whatwg_css_tokenizer + substrate_browser_phase_2_seed lineage_id: nishi_browser_css_tokenize_v1 nx_safety_envelope: intended_use: "CSS tokenizer -- browser front-end style apply"

dependencies 1 imports · 39 importers

nx_syscalls.nx nx_css_tokenize.nx nx_align_gate.nx nx_browser_demo_html.nx nx_browser_demo_html_nishi.nx nx_browser_demo_styled.nx nx_css_apply.nx nx_css_apply_test.nx nx_css_boxmap_test.nx nx_css_cascade_test.nx nx_css_parse.nx nx_css_parse_test.nx

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

imports: nx_syscalls.nx

imported by: nx_align_gate.nxnx_browser_demo_html.nxnx_browser_demo_html_nishi.nxnx_browser_demo_styled.nxnx_css_apply.nxnx_css_apply_test.nxnx_css_boxmap_test.nxnx_css_cascade_test.nxnx_css_parse.nxnx_css_parse_test.nxnx_css_selector_match.nxnx_css_selector_match_test.nxnx_css_tokenize_test.nxnx_flexgrow_gate.nxnx_flexgrow_probe.nxnx_float_gate.nxnx_float_test.nxnx_grid_gate.nxnx_grid_test.nxnx_grid_track_gate.nxnx_justify_gate.nxnx_layout_block.nxnx_layout_block_horizontal_test.nxnx_layout_block_test.nxnx_layout_debug.nxnx_negmargin_gate.nxnx_paint_box_borders.nxnx_paint_box_borders_test.nxnx_paint_walk_layout.nxnx_paint_walk_layout_test.nxnx_paint_walk_layout_text_test.nxnx_real_page_gate.nxnx_render_ascii.nxnx_render_html.nxnx_render_wiki_bmp.nxnx_render_wiki_styled_window.nxnx_render_wiki_window.nxnx_table_cell_gate.nxnx_wiki_boxdump.nx

structs

71struct CssToken
82struct CssCursor

consts

52const NX_CSS_TOK_UNKNOWN: i64 = 0
53const NX_CSS_TOK_IDENT: i64 = 1 // body / div / color / margin
54const NX_CSS_TOK_DOT: i64 = 2 // .
55const NX_CSS_TOK_HASH: i64 = 3 // # (class or color prefix)
56const NX_CSS_TOK_COLON: i64 = 4 // :
57const NX_CSS_TOK_SEMI: i64 = 5 // ;
58const NX_CSS_TOK_LBRACE: i64 = 6 //
59const NX_CSS_TOK_RBRACE: i64 = 7 // }
60const NX_CSS_TOK_COMMA: i64 = 8 // ,
61const NX_CSS_TOK_WHITESPACE: i64 = 9 // descendant combinator
62const NX_CSS_TOK_STRING: i64 = 10 // "Arial" / 'sans-serif'
63const NX_CSS_TOK_NUMBER: i64 = 11 // 16 / 1.5
64const NX_CSS_TOK_UNIT: i64 = 12 // px / em / rem / % (follows NUMBER)
65const NX_CSS_TOK_HEXCOLOR: i64 = 13 // #ff0000 / #fff (recognized as a unit)
66const NX_CSS_TOK_EOF: i64 = 14
67const NX_CSS_TOK_N: i64 = 15
79const NX_CSS_TOKEN_BYTES: i64 = 40
88const NX_CSS_CURSOR_BYTES: i64 = 24

functions

92func _css_is_space(c: i64) -> i64
called by 1: nx_css_next_token
101func _css_is_alpha(c: i64) -> i64
111func _css_is_digit(c: i64) -> i64
118func _css_is_hex(c: i64) -> i64
130func _css_is_ident_start(c: i64) -> i64
called by 1: nx_css_next_token calls 1: _css_is_alpha
138func _css_is_ident_continue(c: i64) -> i64
148func _css_peek(cur: *CssCursor, offset: i64) -> i64
157func _css_consume_ident(cur: *CssCursor) -> i64
178func _css_consume_hex_run(cur: *CssCursor) -> i64
198func _css_consume_number(cur: *CssCursor) -> i64
236func _css_consume_string(cur: *CssCursor, quote: i64) -> i64
called by 1: nx_css_next_token calls 1: _css_peek
262func nx_css_cursor_init(cur: *CssCursor, src: *u8, src_len: i64) -> i64
271func nx_css_next_token(cur: *CssCursor, tok: *CssToken) -> i64