Module parser

Module parser 

Source
Expand description

STEP/IFC Parser using nom

Zero-copy tokenization and fast entity scanning.

Two independent algorithms live here:

  • [tokenizer]: nom-combinator tokenization (Token, parse_entity).
  • [scanner]: a byte-level SIMD fast scanner (EntityScanner) that does its own hand-rolled parsing and never touches Token or nom.

[lexical] holds one small piece shared by both, and by other crates: skip_step_comment is the STEP /* ... */ comment-skip rule, in one place so every scanner that has no reason to answer “what does an unterminated comment mean” differently gives the same answer (#3303). [keyword] is the other shared rule: the scanner returns the keyword as written and STEP keyword case is not significant, so every comparison against a literal goes through keyword_eq and its siblings. header reads ISO 10303-21 header records for exporters and source views.

Re-exports§

pub use header::declared_schema_bounded;

Modules§

header
Shared, quote-aware ISO 10303-21 header record and schema reading. The export writer and analytic processing use the same lexical rules.

Structs§

EntityScanner
Fast entity scanner over raw IFC bytes without full parsing. O(n) performance for finding entities by type Uses memchr for SIMD-accelerated byte searching
StepListItems
The top-level items of one parenthesized STEP list, each trimmed of trivia (STEP whitespace and /* ... */ comments) at both ends. Nested parentheses and quoted strings are respected, so a , inside ('a,b') or (#1,#2) does not separate items, and a comment is trivia wherever ISO 10303-21 allows one: a ,, (, ) or ' inside it is comment text.

Enums§

Token
STEP/IFC token.

Functions§

entity_count
Count the entities in a STEP/IFC byte buffer in O(scan) time and O(1) memory — no entity index, no per-type map.
find_keyword
Byte offset of the first case-folded occurrence of upper in content, anywhere (not only at a record’s keyword position): the whole-file “is this entity present at all” prefilter. upper must be uppercase ASCII and non-empty.
keyword_ends_with
keyword_eq for a suffix: true when raw ends with upper, case folded. upper must be uppercase ASCII.
keyword_eq
True when the raw keyword raw spells upper under STEP’s case-insensitive keyword rule. upper must be uppercase ASCII.
keyword_starts_with
keyword_eq for a prefix: true when raw begins with upper, case folded. upper must be uppercase ASCII.
nth_attribute_is_present
Whether the top-level attribute at index (0-based, first attribute after the () of a STEP record holds a value: it exists, it is not $, and it is not an empty slot (,,). Attributes are split by StepListItems, so nesting, strings and comments follow its rule, and whitespace is the STEP set (is_step_space), including the vertical tab and form feed that u8::is_ascii_whitespace leaves out.
oversized_id_report
The one-line report for skipped refused records, or None when the scan refused nothing.
parse_entity
Parse a complete entity line from raw IFC bytes. Example: #123=IFCWALL(‘guid’,‘owner’,$,$,‘name’,$,$,$);
report_malformed_records
Emit [MALFORMED_RECORD_MESSAGE] to the installed sink (stderr by default; see super::set_report_sink).
report_oversized_ids
Emit oversized_id_report to the installed sink (stderr by default).
report_scan_diagnostics
report_oversized_ids + report_malformed_records in one call — the two diagnostics every whole-file EntityScanner walk in this workspace emits after a scan, so every call site needs only one line, not two.
set_report_sink
Route every scan diagnostic in this crate — report_oversized_ids and super::malformed_records::report_malformed_records alike — to sink instead of stderr.
skip_step_comment
If a STEP /* ... */ comment starts at bytes[i], the index just past its closing */.