Skip to content

Releases: DrSensor/scdlang

Release v0.2.0 (Syntax Sugar)

09 Jul 05:58
Compare
Choose a tag to compare

📰 See more on the Release Article

✔ New shortcut syntax
✔ New target transpilation
✔ Integrate with others CLI

quick_demo

Changes:

New Supported Format

🗹 State Machine Cat

New Syntax

This new syntax symbols will desugar into several expressions. For best experience, use fmonospaced font with programming ligatures like FiraCode

🗹 Toggle Transition

A <-> B @ Toggle

👆 will desugar into 👇

A -> B @ Toggle
A <- B @ Toggle

release

🗹 Loop Transition

A ->> B @ Loop
// or
B <<- A @ Loop

👆 will desugar into 👇

A -> B @ Loop
B -> B @ Loop

release

🗹 Transient Loop Transition

A >-> B @ Loop
// or
B <-< A @ Loop

👆 will desugar into 👇

A -> B
B -> B @ Loop

release

🗹 Self Transition

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

release

CLI (see usage)

Breaking changes

🗹 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)

New Features

🗹 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

🗹 Hook to others CLI

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:

Live preview the visual representation in terminal window

live preview boxart.gif

Live preview the visual representation in the VSCode (output must be png, jpg, or similar)

live preview png.gif

Live preview the visual representation as SVG format in the web browser

live preview svg.gif

Release v0.1.0 (Basic State Machine)

31 May 17:06
Compare
Choose a tag to compare

📰 See more on the Release Article

Changes:

Supported Format

🗹 XState

Syntax

🗹 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
  • Some symbol can be used for break-line. For example:
/*
bunch of expressions
*/
Z ---------------------------> A @ Reset
🗹 Transient transition
"get🆙" -> Walk
🗹 Eventful/Triggered transition
On -> Off @ Shutdown

CLI

Disable colored output when piped

🗹 Transpile or Generate to others format

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.

🗹 REPL

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.