Skip to content

thautwarm/JML.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JML: A ML dialect based on Julia

P.S: The python backend is broken.

The Syntax rules of JML could be found at Parser.jl. Not all valid syntax constructs are implemented in the compiler yet. Type checker is WIP.

Features

  • infix operators with custom associativities and precendences:

        infix add 5
        infix cons 2 right
    
  • pure lexical scope, and distinguish let-in bindings from let rec - in bindings.

  • FFI via foreign keyword

        foreign Base
        def p = Base.getproperty
    
  • provide accurate source code positions when reporting errors

  • match expression

  • type inference with type classes

  • parameterised modules

Usage

Press \ to enter jml mode.

julia> \
jml>

jml

Constructs Support Status

  • Str := value=str
  • Nil := ["()"]
  • Bind := [name=id %get_str, '=', value=Exp]
  • Let := [loc=:let %get_loc, rec=:rec.? % maybe_to_bool, ...
  • Fun := [loc=:fn %get_loc, "(", args=join_rule(",", ...
  • Match := [loc=:match %get_loc, sc=Exp, :with,
  • If := [loc=:if %get_loc, cond=Exp, :then, ...
  • Num := [neg="-".? % maybe_to_bool, (int=integer) | (float=float)]
  • Boolean := value=("true" | "false")
  • NestedExpr = ['(', value=Exp, ')'] => _.value
  • Var := value=id %get_str
  • Block := [loc='{' %get_loc, stmts=Stmt{*}, '}']]
  • Atom = Nil | NestedExpr | Num | Str | Boolean | Var | List
  • Attr := [value=Atom, attrs=(['.', id % get_str] % second){*}]
  • Call := [fn=Attr, ['(', args = join_rule(",", Attr), ')'].?]
  • List := [loc='[', elts=join_rule(',', Exp), ']']
  • Comp = Call | Let | Fun | Match | If | Block
  • Op := ...
  • Top := [hd=Comp, tl=[Op, Comp]{*}]
  • Custom := [value=Exp, [',', next=Custom].?] | [kw=id, value=Exp, [',', next=Custom].?]
  • Exp := [top=Top, [do_custom::Bool='{' => true, [custom=Custom].?, '}'].?]
  • Define := [loc=:def %get_loc, name=id_str, '=', value=Exp]
  • Infix := [loc=:infix %get_loc, name=id_str, prec=integer %get_str, is_right="right".? % maybe_to_bool]
  • Foreign := [loc=:foreign %get_loc, paths=join_rule('.', id_str)]
  • Import := [loc=:import %get_loc, is_qual=:qualified.? %maybe_to_bool, paths=join_rule('.', id_str)]
  • Ops := [loc=:export %get_loc, names=id_str{*}]
  • Stmt = [Exp | Import | Module, ';'.?] % first
  • TopStmt = Define | Import | Infix | Stmt | Foreign | Ops
  • [?] Module := [loc=:module %get_loc, name=id_str, params=id_str{*}, :where, stmts=TopStmt{*}, :end.?]

About

A ML dialect based on Julia, for MLStyle examples.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published