Expand description
NASA/DO-178B-grade Rust DSL for type-safe JavaScript generation.
§Overview
probar-js-gen provides a type-safe DSL for generating JavaScript code
with compile-time validation, runtime verification, and immutability
enforcement. The generated code is deterministic and verifiable.
§Key Features
- Type Safety: Invalid JS constructs are unrepresentable
- Identifier Validation: Reserved words and invalid chars are rejected
- Immutability: Generated files include hash manifests
- Determinism: Same input always produces same output
§Example
use probar_js_gen::prelude::*;
// Build a JavaScript module
let module = JsModuleBuilder::new()
.comment("Generated by probar-js-gen")
.let_decl("x", Expr::num(42)).unwrap()
.const_decl("msg", Expr::str("hello")).unwrap()
.build();
// Generate JavaScript code
let js = generate(&module);
assert!(js.contains("let x = 42;"));§Safety Model
The crate enforces several safety properties:
- No Raw JS: All JavaScript is generated from typed HIR
- No Reserved Words: Identifier::new() rejects
class,function, etc. - No Invalid Chars: Identifiers are validated at construction
- Manifest Verification: Generated files are hash-verified
§References
§Formal Methods
- McKeeman, W.M. (1998) “Differential Testing for Software”
- Claessen, K. & Hughes, J. (2000) “QuickCheck”
- DeMillo, R.A. et al. (1978) “Hints on Test Data Selection”
§JavaScript Semantics
- Maffeis et al. (2008) “An Operational Semantics for JavaScript”
- Guha et al. (2010) “The Essence of JavaScript”
- ECMA-262 (ES2022) Specification
§Software Safety
- Leveson, N. (2012) “Engineering a Safer World”
- DO-178C (2011) “Software Considerations in Airborne Systems”
Re-exports§
pub use error::JsGenError;pub use error::Result;
Modules§
- builder
- Fluent builder API for JavaScript generation.
- codegen
- Code generation from HIR to JavaScript.
- error
- Error types for
probar-js-gen. - hir
- High-level Intermediate Representation for JavaScript.
- manifest
- Manifest system for immutability enforcement.
- prelude
- Prelude module for convenient imports.
- validator
- Validator for generated JavaScript.