Git Product home page Git Product logo

elk's People

Contributors

samtebbs33 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

elk's Issues

Rewrite v2

The whole system should be replaced with a more modular system, consisting of a frontend, midend and backend:

  • Frontend: Consists of a grammar for the language and a parser that parses that grammar and converts it into a JSON syntax tree.
  • Midend: Provides a mapping between Elk syntax elements and HTML. The mapping comes in the form of a JSON object with each element specifying its components and how its HTML is computed.
  • Backend: Performs the conversion between Elk and HTML according to the mapping. This should just require running an interpreter to interpret the mapping code, providing it with some hooks (template storage) and the syntax elements given in the syntax tree.

An example of a syntax tree for


html {
  h1: Hi!
}

would e.g. be

{
  "class": "StatementBody",
  "terminal": false,
  "fields": [
    {
      "class": "Tag",
      "terminal": false,
      "fields": [ { "class": "ID", "terminal": true, "value": "html" },
        {
          "class": "StatementBody",
          "terminal": false,
          "fields": [
            {
              "class": "Tag",
              "terminal": false,
              "fields": [{ "class": "String", "terminal": true, "value": "hi!" }]
            }
          ]
        }
        ]
    }
  ]
}

A midend mapping for a Tag could look something like:

{
  "name": "Tag",
  "fields": [ { "name": "id", "class": "ID" }, { "name": metadata", "class": "Metadata" }, { "name": "body", "class": "StatementBody" } ],
  "mapping": "return '<$id $metadata>$body</$id>'"
}

This would make porting to other platforms (e.g. Java, C, Scala) much simpler since only the parser and backend have to be re-implemented for the new platform, rather than that as well as the mapping and class structure.

Match equality function

Make it possible to provide a custom equality definition that the match statement uses to decide which case(s) to follow.

`
match $x {
...
}

template sameType(a, b): return typeOf(a) == typeOf(b)

match $y by sameType {
...
}
`

Clean up template system.

The following functions should be removed or merged into others:

  • addTemplateFunction -> addTemplate
  • getTemplateFunction -> getTemplate
  • etc.

Clean up repo

There are files in the repo that need to be deleted or moved:

To delete:

  • res
  • data.json
  • build.sh

To move:

  • design.md

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.