Giter VIP home page Giter VIP logo

sealark's Introduction

Sealark - tools for Starlark parsing and editing

Sealark is a collection of tools for working with Starlark code, written in C (get it, C-lark?). libsealark is a Starlark parser; Sunlark is a Scheme binding; Moonlark is a Lua binding;

List of lark species. Sunlark is actually a species.

STATUS Beta-ish. Used by Sunlark; documentation is on the way.

libsealark

libsealark is a C11 library that contains routines to parse files and strings of Starlark code, producing a simple AST. It also contains some serialization routines to write the AST to a string. The result can be compared to the original input. (The goal is a 100% match, including whitespace and comments).

libsealark uses re2c for lexing, lemon for parsing, and uthash for C data structures. Experienced C programmers will notice there are no header (.h) files in the source tree. That's because it uses Makeheaders, which automatically generates one header for each source file, containing everything it needs (and nothing more). Each BUILD.bazel file contains a :mkhdrs target that runs makeheaders. In addition sealark/BUILD.bazel has a :mkhdrs-export that generates the sealark.h public API.

Currently libsealark does not contain a public API for manipulating the AST. A developer could easily implement such routines, however, since the AST is pretty simple, and it uses utarray and utstring from the UTHash library.

Instead, the parsing routines of libsealark are exposed in sunlark, a Scheme binding, which also exposes the parsed AST. AST manipulation and serialization can then be implemented in Scheme code. The idea is that this will make customization much easier, thus enabling tool makers to build a variety of tools on top of sunlark/sealark. Default implementations are provided, but the user can easily supply alternatives.

A Lua binding, Moonlark, is partially implemented.

testing

$ bazel run test:lex_file -- -f path/to/BUILD
$ bazel run test:parse_file -- -f path/to/BUILD

Unit tests are currently in Sunlark.

sealark's People

Contributors

mobileink avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

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.