Skip to main content

Crate netform_ir

Crate netform_ir 

Source
Expand description

lossless intermediate representation (IR) for network device configuration text.

this crate provides:

  • a tree model (Document, Node, LineNode, BlockNode)
  • a conservative parser (parse_generic, parse_with_dialect)
  • a lossless renderer (Document::render)

the parser is intentionally conservative:

  • it only uses indentation as a structural cue
  • unknown patterns are preserved as regular lines
  • no input lines are dropped

§Example

use netform_ir::parse_generic;

let input = "interface Ethernet1\n  description uplink\n";
let doc = parse_generic(input);
assert_eq!(doc.render(), input);

Modules§

detect
score-based dialect auto-detection from configuration text.

Structs§

BlockNode
structured block node with a header line and nested children.
Document
lossless parsed document backed by an arena and root node list.
DocumentMetadata
document metadata attached during parsing.
GenericDialect
conservative default dialect for vendor-agnostic parsing.
IosKeyHintConfig
configuration for ios_family_key_hint, parameterizing the constructs that differ across IOS-family dialects while sharing the common structure.
IosLikeDialect
parameterized dialect for IOS-like configuration text (EOS, IOS XE, NX-OS, …).
LineNode
leaf node preserving original raw text and parse metadata for one line.
NodeId
stable arena identifier for a node in a Document.
ParseFinding
parser-level uncertainty note attached to a source span.
ParsedLineParts
minimal tokenized representation of a content line.
Path
location path used by diffs and diagnostics (root_index, then child indices).
Span
source span pointing to a single line and byte range in the original input.

Enums§

DialectHint
declared parser dialect used for this document.
LiteralTerminator
what closes a multi-line literal region opened by Dialect::literal_region.
Node
arena node variant.
TriviaKind
lightweight classification used by parser, normalization, and diff views.

Traits§

Dialect
dialect extension point for trivia classification and line tokenization.

Functions§

classify_ios_like_trivia
classify trivia for IOS-like dialects (EOS, IOS XE).
classify_trivia_with_prefixes
classify a line as blank, comment, or content based on the given comment prefixes.
common_key_hint
derive a stable identity key for constructs shared across all IOS-like dialects (EOS, IOS XE, NX-OS).
count_indent
count the visual indentation width of a line, treating tabs as 4 spaces.
ends_inside_quoted_value
report whether raw ends with a double-quoted value still open.
ios_family_key_hint
derive a key hint for constructs shared across IOS-family dialects.
ios_like_literal_region
recognize an IOS-family banner <type> [delimiter] line and report what closes the free-text body that follows it.
parse_generic
parse input using the built-in generic dialect.
parse_interface
parse an interface name into (canonical_type, id) using the given type prefix table.
parse_ios_like_parts
tokenize a content line for IOS-like dialects (EOS, IOS XE).
parse_with_dialect
parse input into a lossless IR using the given dialect implementation.
tokenize
tokenize a raw configuration line, splitting on whitespace while preserving quoted strings. characters in punctuation are emitted as their own tokens (flushing any accumulated word first), matching the Junos-style brace/semicolon handling.