Coder Social home page Coder Social logo

mutegrammar's Introduction

MuteGrammar

ANTLR v4 Grammar and interpreter for aliceffekt's mute scripting language.

How to test

Using the jar file

With a file as input

In a command line environment with Java 7 JRE installed, run :

java -jar MuteInterpreter.jar <filename>

Where <filename> is a text file containing valid mute code.

As an interactive interpreter

If the <filename> is omitted, an interactive mode starts instead, which allows you to enter Mute statements line by line and seeing the results.

C:\Users\Renaud\workspace\MuteGrammar>java -jar MuteInterpreter.jar

Mute Interactive Interpreter (version 1.0)
==========================================
Type exit to exit.

> a[1]
> a{"@",$}
1
> exit
Exiting.

Using the ANTLR4 tools

  • See "Getting Started" instructions at http://www.antlr.org/ to have the aliases ready
  • antlr4 .\src\Mute.g4
  • javac -d .\bin .\src\Mute*.java
  • grun .\bin\Mute parse -gui
  • Enter mute script in console window followed by ^D (or ^Z in Windows)

Status

The Mute.g4 grammar will parse everything from the official Mute benchmark at the time of this writing. MuteInterpreter.jar supports everything except modules, but has low error tolerance. See demo.mute to see what's supported and tested for.

Current parsing limitations

  • Requires identifiers (names) to be at the beginning of a statement
  • Statement fragments that follow a module declaration must obey standard condition/assignation/operation block structure, but mute may accept anything at all as per the current spec
  • Identifiers must be ascii characters, unicode is not currently supported
  • Mac-style carriage returns without line feeds are not supported
  • The lexer will complain if it doesn't see an EOL before the EOF...

mutegrammar's People

Contributors

renaudbedard avatar lqd avatar

Stargazers

Mahmoud Rusty Abdelkader avatar Sarah Badr avatar Zander Milroy avatar Devine Lu Linvega avatar

Watchers

 avatar James Cloos avatar Zander Milroy avatar Devine Lu Linvega avatar

Forkers

mutelang

mutegrammar's Issues

Change the meaning of the colon and dot operators

Instead of doing

a[b:1]

to put a value called "b" inside "a" and assign it to 1, use

a.b[1]

This frees up the colon operator which will be reused for indexing, as follows

a[2]
b[1, 2, 3]
{"@", b:a} # prints 3

The indexing operator could also be used for assignment

a[1, 2, 3]
a:2[4] # a[1, 2, 4]
b[1]
a:b[5] # a[1, 5, 4]

Dot (dereferencing?) and colon (indexing) operators are chainable as well

a.b[0]
c[1, 2, 3]
c:a.b[9] # c:0[9]; c[9, 2, 3]
d[2, 3]
c:d:a.b[99] # c:d:0[99] โ‡” c:2[99]; c[9, 2, 99]

(operator precedence is still not 100% clear, there are probably ambiguous corner cases to look at)

Indexing by a multi-value is invalid, it could either blow up or take the first element and ignore the rest.

a[1, 2]
b[3, 4]
c["foo"]
d.x["bar"]
b:a[1] # either blows up or assigns at index 1
b:c[1] # definitely blows up
b:d[1] # that too, and would blow up even if d.x contained a number

(to be continued...)

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.