Git Product home page Git Product logo

slicec-old's Introduction

Slice Compiler Library (slicec)

.github/workflows/rust.yml

Build Requirements

To build the slicec library you need to have Rust and Cargo installed. The recommended method to install Rust is by using rustup.

Overview

The slicec library is a Rust library that can be used to compile Slice definitions into a CompilationState struct. The CompilationState struct contains the AST and any diagnostics that were emitted during compilation.

Compile from strings

The simplest way to compile a Slice definition is by using the compile_from_strings function:

pub fn main() {
    let slice = "

    module GreeterExample

    /// Represents a simple greeter.
    interface Greeter {
        /// Creates a personalized greeting.
        /// @param name: The name of the person to greet.
        /// @returns: The greeting.
        greet(name: string) -> string
    }
    ";

    let compilation_state = slice::compile_from_strings(&[slice], None);
}

This function takes an array of strings containing Slice definitions and an optional set of compilation options.

Compile from options

Alternatively, you can create SliceOptions and use the compile_from_options function to create a command line application that compiles Slice definitions:

// main.rs
pub fn main() {
    let options = SliceOptions::parse();
    let slice_options = &options.slice_options;
    let compilation_state = slice::compile_from_options(slice_options);
}
// greeter.slice

module GreeterExample

/// Represents a simple greeter.
interface Greeter {
    /// Creates a personalized greeting.
    /// @param name: The name of the person to greet.
    /// @returns: The greeting.
    greet(name: string) -> string
}

Build and run using Cargo:

cargo build
cargo run greeter.slice

Testing

The test suite can be run from the command line by running cargo test in the repository.

Code coverage report

Code coverage reports can be generated using cargo-llvm-cov from a regular command prompt, using the following command

For Linux and macOS:

cargo install cargo-llvm-cov
cargo llvm-cov --html

The output html is in the target/llvm-cov/html/ directory.

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.