clnhlzmn / makina Goto Github PK
View Code? Open in Web Editor NEWA simple hierarchical state machine compiler that generates C.
License: MIT License
A simple hierarchical state machine compiler that generates C.
License: MIT License
In the generated struct <machine> { ... }
and struct <machine>_event { ... }
there is a void *ctx
. The user should be able to specify the type of ctx
. Maybe it could be passed on the command line (java -jar makina-compiler --machine-context struct my_type input.mkna
) or the generated files could use a macro for that variable's type which would have to be defined by the user.
Maybe Graphviz dot format? I'm not sure if that supports nested nodes (for hierarchical states).
The generated C for this has unreachable code:
machine unreach;
initial state s {
on TERMINATE -> .done;
on I (guard_foo) clear_foo -> done;
state done {}
state s1 {
on I -> done;
state done {}
}
}
state done {
}
like so:
static int unreach_s_s1_done(struct unreach *self, struct unreach_event *event) {
if (!self || !event) return -1;
switch (event->id) {
case unreach_event_I:
if (1) {
self->state = NULL;
self->state = unreach_s_s1_done;
break;
}
if (guard_foo(self, event)) {
self->state = NULL;
clear_foo(self, event);
self->state = unreach_s_done;
break;
}
break;
The if (guard_foo)
is unreachable and the C compiler complains about it.
I'd like to use this for very small 8 bit MCUs like STM8 and Pauduk with the SDCC compiler. Unfortunately SDCC does not optimize away the dead assignments, which bloats the generated code considerably.
If I were greedy, I'd also ask for an option to declare the type of the state variable so I could use uint8_t instead of int.
BTW, I really like the description language and the generated code, so clear and clean.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.