Skip to content

csg-tokyo/typelevelLR

Repository files navigation

TypeLevelLR

  • Fluent DSL Generator

  • Supporting lauguages are:

    • Haskell
    • C++
    • Scala

How to Install

Clone this repository and type stack install.

> git clone https://github.com/csg-tokyo/typelevelLR
> cd typelevelLR
> stack install

You can also use Docker:

> git clone https://github.com/csg-tokyo/typelevelLR
> cd typelevelLR
> docker build -t csg-tokyo/typelevellr:latest .
> docker run -v $(pwd):/workdir -it csg-tokyo/typelevellr:latest

Usage:

  1. Define your syntax
> nano hello.syntax
syntax helloDSL (Start) {
    simpleHello   : Start -> "hello"
    helloWithName : Start -> "hello" Name
    nameString    : Name  -> "name(String)"
}
  1. Generate Fluent DSL Library
> typelevelLR --haskell
  1. Import Fluent DSL Library
> nano MyApp.hs
import HelloDSL

main :: IO ()
main = print $ begin |> hello |> name "ymzk" |> end
> runghc MyApp.hs
HelloWithName (NameString "ymzk")
  1. Define semantics
> nano HelloDSLSemantics.hs
module HelloDSLSemantics where

import HelloDSL

runHelloDSL :: Start -> IO ()
runHelloDSL (SimpleHello name) = putStrLn "Hello."
runHelloDSL (HelloWithName (NameString name)) = putStrLn ("Hello, " ++ name ++ "!!")
  1. Run it
> nano MyApp.hs
module MyApp where

import HelloDSL
import HelloDSLSemantics

main :: IO ()
main = runHelloDSL $ begin |> hello |> name "ymzk" |> end
> runghc MyApp.hs
Hello, ymzk!!

Details of Syntax Files

Will be written.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages