Statechart Description Language (just an experiment, need to be rewritten)
📰 See more on the Release Article
✔ New shortcut syntax ✔ New target transpilation ✔ Integrate with others CLI
🗹 State Machine Cat
This new syntax symbols will desugar into several expressions. For best experience, use fmonospaced font with programming ligatures like FiraCode
A <-> B @ Toggle
👆 will desugar into 👇
A -> B @ Toggle
A <- B @ Toggle
A ->> B @ Loop
// or
B <<- A @ Loop
👆 will desugar into 👇
A -> B @ Loop
B -> B @ Loop
A >-> B @ Loop
// or
B <-< A @ Loop
👆 will desugar into 👇
A -> B
B -> B @ Loop
Not exactly desugar into multiple expressions but this new syntax can give a clear distinction between normal transition and self transition.
->> B @ Loop
👆 is same as 👇
B -> B @ Loop
// or
B <- B @ Loop
🗹 In subcommand code
, positional argument [DIST]
changes to -o, --output
(cause by a bug in [clap][], probably 🤔)
🗹 In subcommand code
and repl
, flag --format <target>
must be specified (to avoid favoritism)
🗹 Add print
command in non-interactive mode (repl
with no --interactive
flag set)
🗹 Add exit
command to close REPL session
🗹 Tweak error prompt color
🗹 In subcommand code
, use special error handle when positional argument <FILE>
is a directory
🗹 Semantic check depend on the output format. For example. --as png
will disable semantic check and instead mark and note the illegal transition.
🗹 Hide empty result when repl -i
piped from stdin (it will not print empty line or comment)
🗹 --output <DIST>
will give an error messages that it must be specified if outputting --as <format>
binary file (e.g --as jpg
)
🗹 --as <format>
will give an error messages if paired with wrong --format <target>
(e.g --format smcat --as boxart
)
🗹 possible values in --as <format>
will be hidden and disabled if certain others CLI not being installed
In this update, scrap
able to support others formats only if this CLI has been installed:
This brings several ability if combined with certain tools, for example:
📰 See more on the Release Article
🗹 XState
🗹 Support both //line
and /*block*/
comments
🗹 If not quoted, state and event name must be in PascalCase
🗹 Supported quotes: single-quote '
, double-quote "
, backtick `
🗹 Only names quoted with backtick will support newline
🗹 Any pre-defined symbol support both direction, either left or right. For example:
On -> Off @ Toggle
On <- Off @ Toggle
/*
bunch of expressions
*/
Z ---------------------------> A @ Reset
"get🆙" -> Walk
On -> Off @ Shutdown
The essential feature of many compiler/transpiler is to output the result. In scrap code
command, the output is base on --format
flag as long as there is no syntax or semantic error. By default, it parses the whole file and outputs it as an XState format (in JSON). To parse it line-by-line, you need to provide --stream
flag which also gives you the partial results.
This is for the sake of prototyping and quickly evaluate some expressions. This REPL subcommand is also pipe friendly just like scrap code
. The only differences are it always outputs line numbers when running on the interactive shell. It also can receive input from stdin
when piped.