Skip to content
D
Documentation

DSL

reference
1 min readUpdated

Import it from @grafloria/engine.

ts
class DSL

Methods

  • constructor(options: DSLOptions = {})
  • parse(text: string): DiagramModel — Parse DSL text into a DiagramModel
  • parseDetailed(text: string): ParseResult — Parse DSL text with detailed results
  • validate(text: string): { valid: boolean; errors: string[] } — Validate DSL text without creating a diagram
  • suggestLayout(text: string): LayoutSuggestion | null — Get layout suggestion for text without parsing fully
  • tokenize(text: string): Token[] — Get token stream for debugging
  • parseToAST(text: string): DiagramNode — Get AST for debugging
  • setOptions(options: Partial<DSLOptions>): void — Set options
  • getOptions(): DSLOptions — Get current options
  • generate(diagram: DiagramModel, options?: GeneratorOptions): string — Generate DSL text from diagram
  • generateFormatted( diagram: DiagramModel, generatorOptions?: GeneratorOptions, formatterOptions?: FormatterOptions ): string — Generate and format DSL text from diagram
  • generatePretty(diagram: DiagramModel, addHeaders: boolean = true): string — Generate pretty-printed DSL text
  • format(text: string, options?: FormatterOptions): string — Format DSL text
  • testRoundTrip(text: string): { success: boolean; originalNodes: number; originalLinks: number; regeneratedNodes: number; regeneratedLinks: number; generatedText: string; } — Round-trip test: parse → generate → parse Returns true if the round-trip preserves structure
  • parseERD(text: string): DiagramModel — Parse ERD (Entity Relationship Diagram).
  • generateERD(diagram: DiagramModel): string — Generate ERD DSL from diagram
  • parseBPMN(text: string): DiagramModel — Parse BPMN (Business Process Model)
  • generateBPMN(diagram: DiagramModel): string — Generate BPMN DSL from diagram
  • parseUML(text: string): DiagramModel — Parse UML Class Diagram.

The scaffolding this replaces returned an EMPTY diagram for canonical classDiagram input.

  • generateUML(diagram: DiagramModel): string — Generate UML DSL from diagram

Was this page helpful?

DSL — Grafloria