unclebob / cc_smc Goto Github PK
View Code? Open in Web Editor NEWState Machine Compiler for Clean Code video series.
State Machine Compiler for Clean Code video series.
CC_SMC/test/smc/optimizer/OptimizerTest.java
Line 370 in 6667ec0
Script started on Fri 06 Apr 2018 10:58:57 AM PDT
$ cd CC_SMC-master/
$ ant compile
Buildfile: /home/dbrower/src/CC_SMC-master/build.xml
compile:
[mkdir] Created dir: /home/dbrower/src/CC_SMC-master/build/classes
[javac] /home/dbrower/src/CC_SMC-master/build.xml:8: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
[javac] Compiling 33 source files to /home/dbrower/src/CC_SMC-master/build/classes
[javac] Note: /home/dbrower/src/CC_SMC-master/src/smc/SMC.java uses unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
BUILD SUCCESSFUL
Total time: 2 seconds
$ and jar
bash: and: command not found
$ ant jar
Buildfile: /home/dbrower/src/CC_SMC-master/build.xml
compile:
[javac] /home/dbrower/src/CC_SMC-master/build.xml:8: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
jar:
[mkdir] Created dir: /home/dbrower/src/CC_SMC-master/build/jar
[jar] Building jar: /home/dbrower/src/CC_SMC-master/build/jar/smc.jar
BUILD SUCCESSFUL
Total time: 0 seconds
$ cd TE��[K��[Ktest_cases/
$ cd c_turnstile/
$ make
rm -f turnstile_test *.o twoCoinTurnstile.h twoCoinTurnstile.c
java -jar ../../build/jar/smc.jar -l C twoCoinTurnstile.sm
Compiled with 0 syntax errors.
cc -c -o turnstile_test.o turnstile_test.c
turnstile_test.c:5:30:fatal error: twoCoinTurnstile.h: No such file or directory
#include "twoCoinTurnstile.h"
^
compilation terminated.
make: *** [turnstile_test.o] Error 1
$ ls
makefile turnstile.h twocointurnstile.c twoCoinTurnstile.sm
turnstileActions.h turnstile_test.c twocointurnstile.h
$ make twoCoinTurnstile.h
java -jar ../../build/jar/smc.jar -l C twoCoinTurnstile.sm
Compiled with 0 syntax errors.
$ ls
makefile turnstile.h twocointurnstile.c twoCoinTurnstile.sm
turnstileActions.h turnstile_test.c twocointurnstile.h
$ make
rm -f turnstile_test *.o twoCoinTurnstile.h twoCoinTurnstile.c
java -jar ../../build/jar/smc.jar -l C twoCoinTurnstile.sm
Compiled with 0 syntax errors.
cc -c -o turnstile_test.o turnstile_test.c
turnstile_test.c:5:30:fatal error: twoCoinTurnstile.h: No such file or directory
#include "twoCoinTurnstile.h"
^
compilation terminated.
make: *** [turnstile_test.o] Error 1
I've thought of a FSM representing a simple handheld calculator. With the current SMC, the definition would be really cumbersome and difficult to build, because each button (digit) press would require a different event. It would be great to have a way to mitigate this problem, but I wonder if that's a good idea or not.
In this case, events should have some kind of optional payload, so the keypad_pressed
event can produce an action consuming the payload of that event like in this:
AwaitingInput
{
OnDigitKeyPress[x] AwaitingInput AppendInput[x]
...
}
This way, upon the code generation stage, the code could pass the parameter x
to the AppendInput
action.
Anyways, building a FSM like this with the SMC is still complex, since pressing an operation key in the calculator will lead you to a different operation state depending on the key, and there may be lots of different operations :)
As I said, it's just a consideration. Maybe somebody could come up with a good approach to use case.
Thanks for reading :)
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.