New package: blocgen, based on plantuml grammar, generate blocs/cubits #71

Open
opened 2022-12-07 23:33:21 +00:00 by hugo · 0 comments
Owner

Using Plantuml grammar, and ANTLR, build a tool to generate States from Plantuml state diagram.


Thougths:

For example, for the grammar:

grammar PlantUmlStateDiagram;

state_diagram : state_definition+;
state_definition : 'state' STRING 'as' ID '{' state_definition* '}';
transition : ID '->' ID ':' STRING;

STRING : '"' (~["])* '"';
ID : [a-zA-Z]+;
WS : [ \t\r\n]+ -> skip;

we can have:

// Define a class for a state in the state diagram
class State {
  final String name;
  final String label;
  final List<Transition> transitions;

  State(this.name, this.label, this.transitions);

  @override
  String toString() => 'State(name: $name, label: $label, transitions: $transitions)';
}

// Define a class for a transition in the state diagram
class Transition {
  final String source;
  final String target;
  final String label;

  Transition(this.source, this.target, this.label);

  @override
  String toString() => 'Transition(source: $source, target: $target, label: $label)';
}

then with a Lexer/Tokenizer/Parser we can have an AST.

finally with build.dart and source_gen.dart we can generate Dart files from the previous tree.

Using Plantuml grammar, and ANTLR, build a tool to generate States from Plantuml state diagram. *** Thougths: For example, for the grammar: ```g4 grammar PlantUmlStateDiagram; state_diagram : state_definition+; state_definition : 'state' STRING 'as' ID '{' state_definition* '}'; transition : ID '->' ID ':' STRING; STRING : '"' (~["])* '"'; ID : [a-zA-Z]+; WS : [ \t\r\n]+ -> skip; ``` we can have: ```dart // Define a class for a state in the state diagram class State { final String name; final String label; final List<Transition> transitions; State(this.name, this.label, this.transitions); @override String toString() => 'State(name: $name, label: $label, transitions: $transitions)'; } // Define a class for a transition in the state diagram class Transition { final String source; final String target; final String label; Transition(this.source, this.target, this.label); @override String toString() => 'Transition(source: $source, target: $target, label: $label)'; } ``` then with a Lexer/Tokenizer/Parser we can have an AST. finally with `build.dart` and `source_gen.dart` we can generate Dart files from the previous tree.
hugo self-assigned this 2022-12-07 23:34:07 +00:00
hugo added the
proposal
label 2023-04-07 12:02:35 +00:00
hugo added the
package
proposal
label 2023-04-07 12:16:08 +00:00
hugo changed title from Proposal(blocgen): based on plantuml grammar, generate blocs/cubits to New package: blocgen, based on plantuml grammar, generate blocs/cubits 2023-04-07 12:16:26 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Wyatt-FOSS/wyatt-packages#71
No description provided.