Skip to main content

Module mini_parser

Module mini_parser 

Source
Expand description

Zero-allocation N-Triples pattern compiler.

Accepts a single N-Triples pattern line such as <http://example.org/Alice> <schema:knows> ?who . and compiles it into a flat bytecode program that webizen::bytecode::execute_program can run directly against a &[NQuin] slice without any heap allocation.

§Bytecode encoding

Each instruction occupies either 1 or 9 bytes:

Opcode byteOperand (bytes 1-8)Meaning
0x01u64 LE hashMatchSubject(hash)
0x02u64 LE hashMatchPredicate(hash)
0x03u64 LE hashMatchObject(hash)
0x04HaltIfFalse (skip this Quin)
0x00End / accept this Quin

Variable tokens (?name) produce no instruction — the corresponding Quin vector is treated as a wildcard.

Enums§

ParseError

Constants§

OP_END
OP_EVAL_FORBID
OP_EVAL_OBLIGATE
OP_EVAL_PERMIT
OP_HALT_IF_FALSE
OP_HALT_VIOLATION
OP_MATCH_OBJECT
OP_MATCH_PREDICATE
OP_MATCH_SUBJECT

Functions§

compile_ntriples_to_bytecode
Compile a single N-Triples pattern line into program.
hash_token
Resolve a single N-Triples token to its 64-bit Quin vector value.