Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
c81265b
Add local config files to .gitignore.
walkie Aug 13, 2021
11b48b9
Add convert_case to dependencies.
walkie Aug 13, 2021
aeeccfb
Refactor to represent state using the enum type.
walkie Aug 16, 2021
f17d9e7
Fix indentation issue.
walkie Aug 16, 2021
7dd7214
Remove comment about bug that was fixed.
walkie Aug 17, 2021
56b6330
Add test that empty state machine compiles.
walkie Aug 17, 2021
d3faffd
Add state parameter tests.
walkie Aug 18, 2021
29abef9
Add broken tests for state variables and event parameters.
walkie Aug 18, 2021
062a9a7
Very partial fix to generator.
walkie Aug 18, 2021
0002c5f
Move state context def generation to separate method.
walkie Aug 20, 2021
152d0d1
Generalize lower_case_methods to follow_rust_naming.
walkie Aug 21, 2021
1a65950
Remove redundant config option.
walkie Aug 23, 2021
26d0f6c
Overhaul and fix state contexts.
walkie Aug 23, 2021
314f210
Rename transition parameter tests.
walkie Aug 23, 2021
dce8356
Test event handler params, variables, and returns.
walkie Aug 24, 2021
ca2e64f
Remove hard-coded frame event names and change default.
walkie Aug 24, 2021
a110837
Apply follow_rust_format everywhere.
walkie Aug 24, 2021
c21d3c8
Suppress dead code warnings in state context types.
walkie Aug 25, 2021
b918999
Run cargo fmt on last few commits.
walkie Aug 25, 2021
dadd519
Add variable scope tests.
walkie Aug 25, 2021
56c31ea
Add interaction test for state context features.
walkie Aug 25, 2021
057f23b
Merge pull request #15 from walkie/simpler-state
frame-lang Aug 25, 2021
1353e84
Remove unused formatting flag.
walkie Aug 25, 2021
8e5c15d
Fix continue operation.
walkie Aug 25, 2021
8d83701
Ignore a continue after a transition or change-state.
walkie Aug 25, 2021
9f3f1a0
Lots of tests for simple hierarchical state machines.
walkie Aug 25, 2021
e51af7d
Fix test name.
walkie Aug 25, 2021
194ec3b
Merge pull request #16 from walkie/fix-continue
frame-lang Aug 26, 2021
d230b3d
Fix negated condition codegen.
walkie Aug 26, 2021
36a3829
Add tests for conditional exprs and branching.
walkie Aug 26, 2021
34d889d
Fix conditional transitions.
walkie Aug 26, 2021
9d8bd69
Test transitions from nested conditionals.
walkie Aug 26, 2021
600b8d4
Tests for guarded transitions in hierarchical state machines.
walkie Aug 27, 2021
82fdee8
Remove trailing whitespace from Frame files.
walkie Aug 27, 2021
c8528ce
Merge pull request #24 from walkie/test-branching
frame-lang Aug 28, 2021
b7ed1b2
# Added code to parser to enforce transitions and state changes to be…
cogiton Aug 28, 2021
08d6ae8
Merge remote-tracking branch 'origin/v0.6.0' into v0.6.0
cogiton Aug 28, 2021
b7e3b5d
Partial work on branching/event handler termination.
cogiton Aug 30, 2021
e566697
- Initial implemntation of new terminator logic compiles
cogiton Aug 30, 2021
eec9855
Run `cargo fmt` on Mark's changes.
walkie Aug 30, 2021
ed0df7a
Test and lots of fixes for follow_rust_naming option.
walkie Aug 30, 2021
0f153a8
Allow unused variables in default action impl.
walkie Aug 31, 2021
35ce24d
Warn about name issues if follow_rust_naming is on.
walkie Aug 31, 2021
1ec540a
Add transition hooks to action trait.
walkie Aug 31, 2021
8ae4d90
Merge pull request #26 from frame-lang/rust-codegen-cleanup
walkie Aug 31, 2021
39abd05
Don't print extra newlines if no context.
walkie Aug 31, 2021
52bb341
Fix change-state transition.
walkie Aug 31, 2021
11cbd65
Make generate_hook_methods a feature.
walkie Aug 31, 2021
2157930
Add transition/change-state tests.
walkie Aug 31, 2021
298d4ce
Merge pull request #28 from frame-lang/more-tests
walkie Aug 31, 2021
8369385
Lots of tests for integer/string matching.
walkie Sep 1, 2021
0c0ef36
Merge pull request #30 from frame-lang/more-tests
walkie Sep 1, 2021
9ebe8f4
- Initial implemntation of new terminator logic compiles
cogiton Sep 2, 2021
13a3f35
Make remaining hard-coded names configurable.
walkie Sep 2, 2021
078c2da
Begin state-context refactor.
walkie Sep 2, 2021
49cc9ca
Remove dependence on transition node in helper functions.
walkie Sep 2, 2021
36fa93d
Fix typo in field name.
walkie Sep 2, 2021
fa17543
Comments and minor re-org of generate transition.
walkie Sep 2, 2021
ef49ae4
Generate state contexts on change-state.
walkie Sep 2, 2021
0ee1d33
Vary the number of parameters in test.
walkie Sep 2, 2021
855edf6
Fix state contexts that require enter args on state-change.
walkie Sep 3, 2021
dcbe64b
Proper branch termination provisionally working.
cogiton Sep 3, 2021
887755c
Formatting
cogiton Sep 3, 2021
cca2a42
Update context on change-state, initial tests.
walkie Sep 3, 2021
ab5b72b
Fix parsing of change-state context, more tests.
walkie Sep 3, 2021
3f50559
Fix and test state contexts for initial states.
walkie Sep 3, 2021
cfbadd2
Basic state stack push/pop is working.
walkie Sep 4, 2021
20618ff
Merge pull request #31 from frame-lang/fix-state-context
frame-lang Sep 4, 2021
7c37ce2
Add ignored test for pop change-states (currently unimplemented).
walkie Sep 4, 2021
3ca27d0
Merge branch 'issue_17' of github-frame-site:frame-lang/frame_transpi…
cogiton Sep 4, 2021
ce2fe65
Support strings for proper termination logic.
cogiton Sep 5, 2021
a2f90af
Finished logic for properly terminating number conditional test.
cogiton Sep 5, 2021
2df07bb
Merge branch 'issue_17' into v0.6.0
cogiton Sep 5, 2021
10b4c12
Implement stack pop change-states.
walkie Sep 7, 2021
f7c4137
Fix and test state stack + state variables.
walkie Sep 7, 2021
9e12c61
Manually revert termination tracking work.
walkie Sep 11, 2021
97efd0e
No statements after transition/change-state.
walkie Sep 11, 2021
124c844
Merge pull request #33 from frame-lang/termination-rollback
frame-lang Sep 11, 2021
90ada82
Basic state stack push/pop is working.
walkie Sep 4, 2021
6450b5f
Add ignored test for pop change-states (currently unimplemented).
walkie Sep 4, 2021
14c7966
Implement stack pop change-states.
walkie Sep 7, 2021
2900217
Fix and test state stack + state variables.
walkie Sep 7, 2021
e85905f
Merge branch 'fix-state-stack' of github.com:frame-lang/frame_transpi…
walkie Sep 13, 2021
be0b32e
Merge pull request #34 from frame-lang/fix-state-stack
walkie Sep 13, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@
*.idea
*.iml

config.yaml
framec_tests/config.yaml
target
23 changes: 16 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions framec/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "framec"
version = "0.5.1"
version = "0.6.0"
authors = ["Mark Truluck <mark@frame-lang.org>"]
edition = "2018"

Expand All @@ -9,13 +9,14 @@ edition = "2018"
crate-type = ["cdylib", "rlib"]

[dependencies]
wasm-bindgen="0.2"
convert_case = "0.4.0"
downcast-rs = "1.2.0"
# runtime-fmt = "0.4.1"
exitcode = "1.1.2"
fomat-macros = "0.3.1"
# runtime-fmt = "0.4.1"
structopt = "0.3.21"
exitcode = "1.1.2"
wasm-bindgen = "0.2"
yaml-rust = "0.4.5"

[package.metadata.wasm-pack.profile.release]
wasm-opt = false
wasm-opt = false
2 changes: 1 addition & 1 deletion framec/src/frame_c/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ impl EventHandlerNode {
state_name,
msg_t,
statements,
terminator_node,
terminator_node: terminator_node,
event_symbol_rcref,
event_handler_has_transition,
line,
Expand Down
2 changes: 1 addition & 1 deletion framec/src/frame_c/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use yaml_rust::YamlLoader;
/* --------------------------------------------------------------------- */

static IS_DEBUG: bool = false;
static FRAMEC_VERSION: &str = "emitted from framec_v0.5.1";
static FRAMEC_VERSION: &str = "emitted from framec_v0.6.0";

/* --------------------------------------------------------------------- */

Expand Down
20 changes: 11 additions & 9 deletions framec/src/frame_c/default_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ codegen:

rust:
features:
lower_case_states: false
introspection: true
generate_action_impl: true
generate_hook_methods: true
follow_rust_naming: true
code:
actions_prefix:
actions_suffix: Actions
Expand All @@ -16,31 +16,33 @@ codegen:
enter_msg: Enter
exit_msg: Exit
enter_args_member_name: enter_args
enter_args_suffix: EnterArgs
exit_args_member_name: exit_args
state_args_var: state_args
state_args_suffix: StateArgs
state_vars_var_name: state_vars
state_vars_suffix: StateVars
state_context_name: StateContext
state_context_suffix: StateContext
state_context_var_name: state_context_rc
state_context_var_name_suffix: _state_context
state_context_struct_name: StateContext
state_context_var_name: state_context
state_context_method_suffix: _context
this_state_context_var_name: this_state_context
frame_event_message_type_name: FrameMessage
frame_event_type_name: FrameEvent
frame_event_parameter_type_name: FrameEventParameter
frame_event_parameters_type_name: FrameEventParameters
frame_event_return: FrameEventReturn
frame_event_variable_name: e
frame_event_variable_name: frame_event
frame_event_parameters_attribute_name: parameters
frame_event_message_attribute_name: message
frame_event_return_attribute_name: ret
frame_state_type_name: FrameState
state_var_name: state
state_var_name_prefix:
state_var_name_suffix: _state
state_handler_name_prefix:
state_handler_name_suffix: _handler
state_enum_suffix: State
state_enum_traits: Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord
initialize_method_name: initialize
handle_event_method_name: handle_event
transition_method_name: transition
change_state_method_name: change_state
transition_hook_method_name: transition_hook
Expand Down
83 changes: 29 additions & 54 deletions framec/src/frame_c/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1059,14 +1059,6 @@ impl<'a> Parser<'a> {
let mut type_node_opt: Option<TypeNode> = None;

if self.match_token(&vec![ColonTok]) {
// if !self.match_token(&vec![TokenType::IdentifierTok]) {
// self.error_at_previous("Expected parameter type.");
// return Err(ParseError::new("TODO"));
// }
//
// let type_name = self.previous().lexeme.clone();
//
// type_opt = Some(type_name);
match self.type_decl() {
Ok(type_node) => type_node_opt = Some(type_node),
Err(parse_error) => return Err(parse_error),
Expand Down Expand Up @@ -1802,7 +1794,6 @@ impl<'a> Parser<'a> {
}

let statements = self.statements();

let event_symbol_rcref = self.arcanum.get_event(&msg, &self.state_name_opt).unwrap();
let ret_event_symbol_rcref = Rc::clone(&event_symbol_rcref);
let terminator_node = match self.event_handler_terminator(event_symbol_rcref) {
Expand Down Expand Up @@ -1910,10 +1901,32 @@ impl<'a> Parser<'a> {

loop {
// let result = self.decl_or_stmt();
// let must_terminate = false;
match self.decl_or_stmt() {
Ok(opt_smt) => match opt_smt {
Some(statement) => {
statements.push(statement);
match &statement {
DeclOrStmtType::StmtT { stmt_t } => {
// Transitions or state changes must be the last statement in
// an event handler.
match stmt_t {
StatementType::TransitionStmt { .. } => {
statements.push(statement);
return statements;
}
StatementType::ChangeStateStmt { .. } => {
statements.push(statement);
return statements;
}
_ => {
statements.push(statement);
}
}
}
_ => {
statements.push(statement);
}
}
}
None => {
return statements;
Expand Down Expand Up @@ -2317,15 +2330,13 @@ impl<'a> Parser<'a> {
expr_t: ExprType,
) -> Result<BoolTestConditionalBranchNode, ParseError> {
let statements = self.statements();

let result = self.branch_terminator();

return match result {
Ok(branch_terminator_t_opt) => Ok(BoolTestConditionalBranchNode::new(
Ok(branch_terminator_expr_opt) => Ok(BoolTestConditionalBranchNode::new(
is_negated,
expr_t,
statements,
branch_terminator_t_opt,
branch_terminator_expr_opt,
)),
Err(parse_error) => Err(parse_error),
};
Expand All @@ -2337,21 +2348,19 @@ impl<'a> Parser<'a> {

fn bool_test_else_branch(&mut self) -> Result<BoolTestElseBranchNode, ParseError> {
let statements = self.statements();

let result = self.branch_terminator();

return match result {
Ok(branch_terminator_opt) => Ok(BoolTestElseBranchNode::new(
Ok(branch_terminator_expr_opt) => Ok(BoolTestElseBranchNode::new(
statements,
branch_terminator_opt,
branch_terminator_expr_opt,
)),
Err(parse_error) => Err(parse_error),
};
}

/* --------------------------------------------------------------------- */

// branch_terminator -> ^ | '>'
// branch_terminator -> '^' | ':>'

// TODO: explore returning a TerminatorType rather than node
fn branch_terminator(&mut self) -> Result<Option<TerminatorExpr>, ParseError> {
Expand Down Expand Up @@ -2488,9 +2497,7 @@ impl<'a> Parser<'a> {
}

let statements = self.statements();

let result = self.branch_terminator();

return match result {
Ok(branch_terminator_t_opt) => Ok(StringMatchTestMatchBranchNode::new(
string_match_pattern_node,
Expand All @@ -2509,9 +2516,7 @@ impl<'a> Parser<'a> {
&mut self,
) -> Result<StringMatchTestElseBranchNode, ParseError> {
let statements = self.statements();

let result = self.branch_terminator();

return match result {
Ok(branch_terminator_opt) => Ok(StringMatchTestElseBranchNode::new(
statements,
Expand Down Expand Up @@ -3366,31 +3371,6 @@ impl<'a> Parser<'a> {

/* --------------------------------------------------------------------- */

// state_context ->

fn change_state_context(
&mut self,
_: Option<ExprListNode>,
) -> Result<Option<StateContextType>, ParseError> {
// parse state ref e.g. '$S1'
if !self.match_token(&vec![TokenType::StateTok]) {
return Err(ParseError::new("Missing $"));
}

if !self.match_token(&vec![TokenType::IdentifierTok]) {
return Err(ParseError::new("Missing state identifier."));
}

let state_id = self.previous();
let name = state_id.lexeme.clone();

let state_context_node = StateContextNode::new(StateRefNode::new(name), None, None);

Ok(Some(StateContextType::StateRef { state_context_node }))
}

/* --------------------------------------------------------------------- */

// transition : exitArgs '->' enterArgs transitionLabel stateRef stateArgs

fn transition(
Expand Down Expand Up @@ -3458,7 +3438,7 @@ impl<'a> Parser<'a> {
}

let state_context_t;
match self.change_state_context(None) {
match self.state_context(None) {
Ok(Some(scn)) => state_context_t = scn,
Ok(None) => return Err(ParseError::new("TODO")),
Err(parse_error) => return Err(parse_error),
Expand Down Expand Up @@ -3558,11 +3538,8 @@ impl<'a> Parser<'a> {
if let Err(parse_error) = self.consume(ForwardSlashTok, "Expected '/'.") {
return Err(parse_error);
}

let statements = self.statements();

let result = self.branch_terminator();

return match result {
Ok(branch_terminator_t_opt) => Ok(NumberMatchTestMatchBranchNode::new(
match_numbers,
Expand All @@ -3581,9 +3558,7 @@ impl<'a> Parser<'a> {
&mut self,
) -> Result<NumberMatchTestElseBranchNode, ParseError> {
let statements = self.statements();

let result = self.branch_terminator();

return match result {
Ok(branch_terminator_opt) => Ok(NumberMatchTestElseBranchNode::new(
statements,
Expand Down
1 change: 1 addition & 0 deletions framec/src/frame_c/visitors/cpp_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1353,6 +1353,7 @@ impl AstVisitor for CppVisitor {

let terminator_node = &evt_handler_node.terminator_node;
terminator_node.accept(self);

self.outdent();

self.newline();
Expand Down
4 changes: 0 additions & 4 deletions framec/src/frame_c/visitors/plantuml_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1251,10 +1251,6 @@ impl AstVisitor for PlantUmlVisitor {

let terminator_node = &evt_handler_node.terminator_node;
terminator_node.accept(self);
// self.outdent();
//
// self.newline();
// self.add_code(&format!("}}"));

// this controls formatting here
self.first_event_handler = false;
Expand Down
Loading