Giter VIP home page Giter VIP logo

jprider63 / daedalus Goto Github PK

View Code? Open in Web Editor NEW

This project forked from galoisinc/daedalus

0.0 1.0 0.0 14.63 MB

The Daedalus data description language

License: BSD 3-Clause "New" or "Revised" License

Haskell 55.57% Racket 0.38% Makefile 0.13% Visual Basic .NET 0.04% Shell 0.37% HTML 27.05% CSS 0.05% PLSQL 8.90% Yacc 1.31% Emacs Lisp 0.43% Vim Script 0.13% Roff 0.01% Common Lisp 0.01% C++ 2.62% Lex 0.33% C 2.15% SMT 0.10% Python 0.28% JavaScript 0.14% Dockerfile 0.01%

daedalus's Introduction

DaeDaLus

Daedalus is a flexible data description language for generating parsers with data dependencies.

Installing Haskell

Daedalus is implemented in Haskell, so to build it you'd need to setup a Haskell environment. An easy way to get this setup is to use ghcup. You need a Haskell compiler (recommended GHC 8.8.3), and a Haskell package installer (recommended Cabal 3.2).

Building the Daedalus Interpreter

The Daedalus interpreter, called daedalus is a good way to experiment with, and learn the Daedlus language. To build and install the interpreter you may use the command:

cabal install exe:daedalus --installdir=DIR \
                           --overwrite-policy=always

This instructs cabal to build Daedlus and place a link to the binary in directory DIR. The flag --overwrite-policy is optional and instructs cabal to overwite existing links with the same name.

Running the Interpreter

To run daedalus you need a Daedalus specification describing the parser, and a file that should be parsed. For example, you could try the following, assuming daedalus is in your path:

daedalus tests/midi/midi.ddl -i tests/midi/inputs/moz_k299.midi

The first argument to daedalus is a specification describing the midi format and the -i flag specfies the input that should be parsed. If the input is parsed successfully, then daedalus will display the resulting semantic value. Otherwise, you should see a parse error describing what went wrong.

Setting up Your Editor

The directory syntax-highlight contain Daedalus syntax hilighting files for common editors.

More about the Daedalus Language

The documentation for Daedlus is not yet complete, but you may read more about the language in docs/UserGuide.pdf. The tests directory contains numerous small examples of Daedlus specifications, of particular interest might be subdirectories ppm (PPM image format), sexp (S-expressions) and midi (MIDI messages).

Generating Parsers

At present we can translate Daedalus specifications into Haskell, so that the resulting parsers may be intergrated with Haskell applications. We are working on adding support for generating parsers in other languages as well. The parser generation functionality is very much in development at the moment.

The repository contains two examples of Haskell applications using Daedalus parsers. They are both validators, for the ICC and PDF format respectively. You may install them using the commands:

cabal install exe:icc-parser    --installdir=DIR
cabal install exe:pdf-hs-driver --installdir=DIR

The source code for the ICC validator is in icc-driver and the source code for the PDF validator is in pdf-driver.

Generating C++ Parsers

The daedalus compiler, given a DaeDaLus format description, can generate a parser in C++ that parses the format. To generate a C++17 parser for a format Main defined in format.ddl, storing the parser in directory parser_dir, run the command

daedalus format.ddl --compile-c++ --out-dir=parser_dir

As a result, parser_dir will contain an implementation of the parser, with header file parser_dir/main_parser.h and and procedure implementations in main_parser.cpp.

The entry procedure of the parser will be named parseMain, and has the following parameters: * an input, of type DDL::Input. In short, a DDL::Input can be constructed

from an Array of bytes or a pointer to a null-terminated sequence of characters.
  • a reference to a DDL::ParseError, where main_parser.cpp stores its result in the case of an error;
  • a reference to a vector of parse results. The class of parse results is declared/defined in main_parser.h / main_parser.cpp, and contains selector methods for accessings its various components.

All classes in the DDL namespace are defined in rts-c/ddl.

The generated parsers require C++17, so to compile them you may need to provide a flag such as std=c++17 to the compiler.

Acknowledgements

This material is based upon work supported by the Defense Advanced Research Projects Agency (DARPA) under Contract No. HR0011-19-C-0073. Any opinions, findings and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the Defense Advanced Research Projects Agency (DARPA).

The Galois DaeDaLus library includes the following third party components:

daedalus's People

Contributors

yav avatar simonjwinwood avatar benoitrazet avatar mtullsen avatar septract avatar phsmenon avatar david-christiansen avatar ptival avatar reiniert avatar jprider63 avatar richard-galois avatar

Watchers

James Cloos 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.