Coder Social home page Coder Social logo

lola's Introduction

Lola

The Language Of Languge Augmentation was found by Iddo Zmiry under the supervision of Prof. Yossi Gil in the Technion. Lola is a tool for language extensions and can equip any language with new syntax and semantics. Lola's syntax is Macro based, and designed to run on a precompiled code, transforming it from the new syntax to the domain syntax. Compared to other preprocessor tools, Lola is much more powerful and even allows the programmer to run python code.

Hello, Lola!

Lola's basic blocks are Lexis. A Lexi defines a pattern of code and some actions to apply on it whenever matched. Typically, a Lexi action will be replacing the code with domain code, asserting that some conditions apply and even running some python code.

Example

Range based loops are fun, they kill boiler plate, but don't exist in Java... Why not add them with the following Lexi?

##Find
  for(##Identifier(id) = ##Literal(from)..##Literal(to))
    ##any(block)
##replace
  for(int ##(id) = ##(from); ##(id) <= ##(to); ++##(id))
    ##(block)
##example
  for(i = 1..100)
    print(i);
##resultsIn
  for(int i = 1; i < 100; ++i)
    print(i);

* In the specification Lola uses @ to denote keywords prefix, but this sign is configurable. When we apply Lola to Java we use ## to not collide with annotations.

As can be deduced from the self explaining exmaple, a pattern is specified to find places where the lexi is used, a replace section specifies domain code to replace the matched code with, an example and resultsIn sections specify an example of usage and the code that will replace the example after applying the Lexi.

Note that the example is not only for documentation but for self testing too, when writing a Lexi, Lola asserts that the example indeed results in the specified resultsIn section code.

Another point worth noting is that Lola uses an environment for identifiers aliasing, meaning, if we write ##Literal(from), the matching literal will be stored in some environment (Jython actually) and may be summoned by the name from. For example, the ## keyword specifies a python snippet to run, so ##(from) will produce the literal matched by from.

Syntax

Lola's syntax is described by Iddo's thesis

Implementation

This version of Lola was implemented by @orimarco using Java 1.8. A detailed explanation about our implementation can be found in the Implementation Wiki.

How do I import the project?

Just clone/download the repository and import the project using Maven. Should be easy!

How do I use Lola?

After importing the project, Lola can be run by compiling Lola.java and running it in this form: Lola <input file> <output file>.

lola's People

Contributors

orimarco avatar m4tt30rru avatar oriroth avatar matteverson avatar

Stargazers

 avatar

Watchers

James Cloos avatar Yossi Gil avatar  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.