Skip to content

Latest commit

 

History

History
149 lines (102 loc) · 5.23 KB

File metadata and controls

149 lines (102 loc) · 5.23 KB

Examples directory

This directory provides hands-on examples and test materials to explore jbeam-edit’s parsing, formatting, and transformation capabilities. It includes raw .jbeam files, example .jbfl configuration rules, parsed AST representations in Haskell, and automatically formatted or transformed outputs.

Example JBeam Files

Directory: examples/jbeam/

Contains the base .jbeam files used for parsing, formatting, and transformation tests.

  • fender.jbeam A simple, clean JBeam file demonstrating basic parsing and formatting. Running jbeam-edit on this file will:

    • Parse the full structure, including comments
    • Apply consistent indentation and spacing
    • Sequentially rename nodes (e.g., bf1-> bf0)
    • Update references accordingly
    • Organize vertices into logical groups (e.g., LeftTree, MiddleTree, RightTree)
  • frame.jbeam A JBeam file representing a structural vehicle frame with two separate node prefixes. This file is intended to test how jbeam-edit merges multiple prefix trees into a single consistent structure. Running jbeam-edit on this file will:

  • Parse nodes and beams across both prefix groups

  • Merge the two prefix trees while preserving structural relationships

  • Sequentially rename nodes and update all cross-prefix references

  • Demonstrate jbeam-edit’s handling of multi-prefix structures for intermediate-level transformation scenarios

  • suspension.jbeam A complex example modeling a vehicle suspension assembly. Demonstrates:

    • Parsing of nodes, beams, and collision triangles
    • Structural renaming with reference updates
    • Preservation of group relationships and suspension geometry

JBFL configuration files

Directory: examples/jbfl/

Contains .jbfl configuration files that define formatting rules.

  • minimal.jbfl — Provides a simple configuration with basic indentation and spacing.
  • complex.jbfl: Demonstrates advanced padding, decimal precision, and line control.

Switch between these configurations to see how JBFL rules influence formatting.

AST source examples

Directory: examples/ast/

Contains Haskell source files showing parsed AST representations of .jbeam and .jbfl files.

  • ast/jbeam/fender.hs
  • ast/jbeam/frame.hs
  • ast/jbeam/suspension.hs
  • ast/jbfl/minimal.hs
  • ast/jbfl/complex.hs

These are used primarily for debugging, testing, and verifying Megaparsec-based parser correctness.

Formatted JBeam Outputs

Directory: examples/formatted_jbeam/

Contains formatted .jbeam outputs produced using different JBFL configurations.

  • fender-minimal-jbfl.jbeam
  • fender-complex-jbfl.jbeam
  • frame-minimal-jbfl.jbeam
  • frame-complex-jbfl.jbeam
  • suspension-minimal-jbfl.jbeam
  • suspension-complex-jbfl.jbeam

These illustrate how rule variations affect indentation, padding, and numeric formatting.

Invalid JBeam Examples

Directory: examples/invalid_jbeam/

Contains malformed JBeam files to test parser error handling.

  • invalid_fender.jbeam: Intentionally invalid syntax to validate parser robustness and error reporting.

Transformed JBeam Outputs

Directory: examples/transformed_jbeam/

Contains JBeam files generated by transformation mode (--transformation flag) or configuration-driven edits.

  • fender-cfg-default.jbeam
  • fender-cfg-example.jbeam
  • frame-cfg-default.jbeam
  • frame-cfg-example.jbeam
  • suspension-cfg-default.jbeam
  • suspension-cfg-example.jbeam

These files show how node renaming, reference updating, and rule-driven transformations are applied.

How JBFL affects formatting

JBFL (JBeam Formatting Language) is a declarative configuration syntax controlling layout behavior for .jbeam files.

  • Wildcard-based section targeting
  • Decimal and padding control
  • Optional newlines and grouping preferences

By switching between the minimal and complex .jbfl configurations, you can observe changes in formatted_jbeam/.

Using these examples

To format an example file with the minimal configuration:

jbeam-edit -cminimal
jbeam-edit examples/jbeam/fender.jbeam

To try the complex configuration, generate it first and run:

jbeam-edit -ccomplex
jbeam-edit examples/jbeam/suspension.jbeam

The resulting formatted outputs will be written to examples/formatted_jbeam/.

yaml configuration file for transformation

The yaml configuration file allows the user to configure custom transformation settings such as a custom support threshold, custom breakpoints for vertex trees or custom support threshold.

File: examples/jbeam-edit.yaml


For complete documentation, refer to the root README.md. See also JBFL_DOCS.md for more details about JBFL syntax and capabilities.