Skip to content

Commit 1585794

Browse files
committed
Add configurable style to smcat output, simplify visitor.
1 parent 9dd1aaa commit 1585794

File tree

5 files changed

+136
-272
lines changed

5 files changed

+136
-272
lines changed

framec/src/frame_c/ast.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,9 @@ impl MachineBlockNode {
351351
pub fn new(states: Vec<Rc<RefCell<StateNode>>>) -> MachineBlockNode {
352352
MachineBlockNode { states }
353353
}
354+
pub fn get_first_state(&self) -> Option<&Rc<RefCell<StateNode>>> {
355+
self.states.get(0)
356+
}
354357
}
355358

356359
impl NodeElement for MachineBlockNode {

framec/src/frame_c/compiler.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -241,13 +241,10 @@ impl Exe {
241241
visitor.run(&system_node);
242242
output = visitor.get_code();
243243
} else if output_format == "plantuml" {
244-
// let x = (&semantic_parser).get_arcanum();
245-
// semantic_parser = semantic_parser.into_inner();
246-
// let y = (&semantic_parser).get_system_hierarchy();
247-
let (x, y) = semantic_parser.get_all();
244+
let (arcanum, system_hierarchy) = semantic_parser.get_all();
248245
let mut visitor = PlantUmlVisitor::new(
249-
x,
250-
y,
246+
arcanum,
247+
system_hierarchy,
251248
generate_state_context,
252249
generate_state_stack,
253250
generate_change_state,
@@ -273,8 +270,11 @@ impl Exe {
273270
visitor.run(&system_node);
274271
output = visitor.get_code();
275272
} else if output_format == "smcat" {
276-
let (x, y) = semantic_parser.get_all();
277-
let mut visitor = SmcatVisitor::new(x, y, FRAMEC_VERSION, comments);
273+
let mut visitor = SmcatVisitor::new(
274+
FRAMEC_VERSION,
275+
config,
276+
semantic_parser.get_system_hierarchy(),
277+
);
278278
visitor.run(&system_node);
279279
output = visitor.get_code();
280280
// } else if output_format == "xstate" {

framec/src/frame_c/config.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,13 @@ pub struct SmcatFeatures {}
188188
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
189189
pub struct SmcatCode {
190190
/// Style settings for nodes that do not have any children.
191-
simple_state_node_style: String,
191+
pub simple_state_node_style: String,
192192
/// Style settings for nodes that have sub-states as children.
193-
parent_state_node_style: String,
193+
pub parent_state_node_style: String,
194194
/// Style settings for "change-state" transitions.
195-
change_state_edge_style: String,
195+
pub change_state_edge_style: String,
196196
/// Style settings for standard transitions.
197-
transition_edge_style: String,
197+
pub transition_edge_style: String,
198198
}
199199

200200
impl FrameConfig {

framec/src/frame_c/parser.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,12 @@ impl<'a> Parser<'a> {
154154

155155
/* --------------------------------------------------------------------- */
156156

157+
pub fn get_system_hierarchy(self) -> SystemHierarchy {
158+
self.system_hierarchy_opt.unwrap()
159+
}
160+
161+
/* --------------------------------------------------------------------- */
162+
157163
pub fn get_all(self) -> (Arcanum, SystemHierarchy) {
158164
(self.arcanum, self.system_hierarchy_opt.unwrap())
159165
}

0 commit comments

Comments
 (0)