Naevier / Domain-Specific-Language

A DSL for drawing manipulation, based on an algebraic approach, with default support for screen printing.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

License GHC version Cabal version Gloss version

Drawing Domain Specific Language

Overview

A DSL for drawing manipulation, based on an algebraic approach. Decouples syntax and semantics for easy customization and modifications for diverse applications. Provides default support for screen printing using Gloss library. Project developed as part of the Programming Paradigms university course at FaMAF - UNC. Language idea based on the Peter Henderson paper

Getting started

  1. Clone the repository
git clone https://github.com/Naevier/Domain-Specific-Language.git
  1. Install ghc and cabal. Then install gloss via cabal (or via or stack)
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh

cabal update
cabal install gloss

Usage

The drawings can be printed from the src directory with

$ ghci Main.hs
ghci> :set args Escher
ghci> main

where the argument (Escher in the example) represents the name of the drawing that will be displayed on the screen, and can be replaced with the name of any other drawing. New drawings can be added creating a new file in the Dibujos directory, importing the new module into the Main file, and adding it to the configs list in the same file.

The complete list of available drawings can be consulted by using --lista as argument.

Escher drawing image

Escher drawing

Running tests

Drawing DSL uses HUnit as a test framework. It can be installed with

cabal install HUnit

and the tests can be run from the test directory over the functions of Dibujo.hs with

$ ghci TestDibujo.hs -i ../src/Dibujo.hs
ghci> main

and over the functions of Pred.hs with

$ ghci TestPred.hs -i ../src/Dibujo.hs ../src/Pred.hs
ghci> main

Files

File Description
Main.hs Main program
Dibujo.hs Data structure and operations for Dibujo type (syntax)
Interp.hs Geometric interpretation of the drawings (semantic) using Gloss
FloatinPic.hs Vector data types and geometric interpretation of the grid
Pred.hs Predicates over drawings (deprecated)
Grilla.hs Functions over the grid
Dibujos/GrillaNumerada.hs Numbered-grid sample drawing
Dibujos/Feo.hs Test drawing that demonstrates the functions
Dibujos/Escher.hs Escher-style recursive drawing
tests/TestDibujo.hs Test suite for the Dibujo module
tests/TestPred.hs Test suite for the Pred module

Each drawing is associated with an instance of the Dibujo type, which includes its own set of basic drawings and semantics. This approach makes it possible to extend the DSL with new basic figures and interpretations of the semantics, such as adding support for SVG printing for example.

The basic figures can be easily changed in the interpBas function of each drawing, and the semantics can be changed in the Interp file

Authors

License

This DSL is licensed under the Apache License, Version 2.0 - See the license file for more information

About

A DSL for drawing manipulation, based on an algebraic approach, with default support for screen printing.

License:Apache License 2.0


Languages

Language:Haskell 100.0%