Giter VIP home page Giter VIP logo

blockly-parser-rs's Introduction

Blockly Parser

Deserialize XML generated by the Google Blockly UI into data structures.

Example usage:

extern crate blockly_parser;

use blockly_parser::{
    Program,
    StatementBody,
    Block,
    FieldValue,
    program_from_xml,
};

fn main() {
    let xml: &str = r#"
        <xml xmlns="http://www.w3.org/1999/xhtml">
            <variables></variables>
            <block type="main_loop" id="[.)/fqUYv92(mzb{?:~u">
                <statement name="BODY">
                    <block type="inner_loop" id="]Lb|t?wfd#;s)[llJx8Y">
                        <field name="COUNT">3</field>
                        <statement name="BODY">
                            <block type="led_on" id="^3xb.m4E9i0;3$R10(=5">
                                <field name="TIME">300</field>
                                <next>
                                    <block type="led_off" id="HX4*sB9=gbJtq$Y{ke6b">
                                        <field name="TIME">100</field>
                                    </block>
                                </next>
                            </block>
                        </statement>
                        <next>
                            <block type="led_on" id="kB~f~7W`wkGa0i4z3mHw">
                                <field name="TIME">100</field>
                                <next>
                                    <block type="led_off" id="$fdlZB)btzA8YtB/!xz`">
                                        <field name="TIME">100</field>
                                    </block>
                                </next>
                            </block>
                        </next>
                    </block>
                </statement>
            </block>
        </xml>
    "#;

    let program: Program = program_from_xml(xml);
    let main_group: StatementBody = program.groups.get(0).unwrap();
    let main_loop_block: Block = main_group.blocks.get(0).unwrap();
}

See the unit tests for more details.

blockly-parser-rs's People

Contributors

andrewjensen avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

linecode

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.