ifc_lite_core/parser/
mod.rs

1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4
5//! STEP/IFC Parser using nom
6//!
7//! Zero-copy tokenization and fast entity scanning.
8//!
9//! Two independent algorithms live here:
10//! - [`tokenizer`]: nom-combinator tokenization ([`Token`], [`parse_entity`]).
11//! - [`scanner`]: a byte-level SIMD fast scanner ([`EntityScanner`]) that does
12//!   its own hand-rolled parsing and never touches [`Token`] or nom.
13//!
14//! [`lexical`] holds one small piece shared by both, and by other crates:
15//! [`skip_step_comment`] is the STEP `/* ... */` comment-skip rule, in one
16//! place so every scanner that has no reason to answer "what does an
17//! unterminated comment mean" differently gives the same answer (#3303).
18//! [`keyword`] is the other shared rule: the scanner returns the keyword as
19//! written and STEP keyword case is not significant, so every comparison
20//! against a literal goes through [`keyword_eq`] and its siblings.
21//! [`header`] reads ISO 10303-21 header records for exporters and source views.
22
23pub mod header;
24mod keyword;
25mod lexical;
26mod malformed_records;
27mod numeric_literal;
28mod oversized_ids;
29mod record_strings;
30mod report_sink;
31mod scanner;
32mod tokenizer;
33
34pub use keyword::{find_keyword, keyword_ends_with, keyword_eq, keyword_starts_with};
35pub use header::declared_schema_bounded;
36pub use lexical::skip_step_comment;
37// The one STEP whitespace set, for the raw-byte readers in `decoder` (#3733).
38pub(crate) use lexical::{is_step_space, skip_step_trivia};
39// The one STEP numeric-literal grammar for every raw-byte reader (#5266).
40pub(crate) use numeric_literal::parse_step_numeric;
41pub use malformed_records::report_malformed_records;
42pub use oversized_ids::{oversized_id_report, report_oversized_ids, set_report_sink};
43pub use scanner::{entity_count, nth_attribute_is_present, EntityScanner, StepListItems};
44pub(crate) use scanner::argument_list_start;
45pub use tokenizer::{parse_entity, Token};
46
47/// [`report_oversized_ids`] + [`report_malformed_records`] in one call — the
48/// two diagnostics every whole-file `EntityScanner` walk in this workspace
49/// emits after a scan, so every call site needs only one line, not two.
50pub fn report_scan_diagnostics(skipped_oversized_ids: usize, malformed_record_found: bool) {
51    report_oversized_ids(skipped_oversized_ids);
52    report_malformed_records(malformed_record_found);
53}