#ast #generation #nets-blox #xml #parser #web-api #programming

no-std bin+lib netsblox-ast

A crate for parsing NetsBlox project files into an AST for use in code generation

60 releases

0.5.9 Mar 27, 2024
0.5.7 Feb 19, 2024
0.5.2 Dec 26, 2023
0.4.4 Nov 17, 2023
0.1.5 Mar 20, 2022

#106 in Programming languages

Download history 17/week @ 2023-12-22 29/week @ 2023-12-29 29/week @ 2024-01-05 15/week @ 2024-02-02 2/week @ 2024-02-09 369/week @ 2024-02-16 70/week @ 2024-02-23 20/week @ 2024-03-01 289/week @ 2024-03-08 282/week @ 2024-03-15 206/week @ 2024-03-22 184/week @ 2024-03-29 30/week @ 2024-04-05

981 downloads per month
Used in 2 crates

MIT/Apache

340KB
6K SLoC

NetsBlox-AST

For the time being, this crate is in active development and its API is highly unstable

NetsBlox is a block-based programming language (extended from Snap!) which provides access to advanced web and distributed computing capabilities such as accessing web APIs and sending messages between clients (e.g. to create multi-user programs). NetsBlox-AST is a rust crate that takes as input a NetsBlox project XML file and outputs a sanitized Abstract Syntax Tree, which is useful for code generation.

Development

This crate is intended to be used directly on some embedded platforms. Thus, because the parser is recursive, we need to keep the stack size to an absolute minimum. To do this, we use cargo-call-stack to check call stack usage.

For the time being, you should install from this fork.

You'll also need dot from graphviz.

sudo apt install graphviz

To generate the call graph, run the following commands:

RUSTFLAGS="-C embed-bitcode" cargo +nightly call-stack --bin netsblox_ast --target x86_64-unknown-linux-gnu >cg.dot
gawk 'match($0, /label="(.*)\\nmax >?= ([0-9]+)\\nlocal = ([0-9]+)"/, m) { print m[3] " " m[1] }' cg.dot | sort -n

Optionally you can generate a visual graph, but this is likely VERY cluttered:

dot -Tsvg cg.dot >cg.svg

Dependencies

~750KB
~13K SLoC