Skip to content

hamler-lang/CoreErlang

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CoreErlang

CoreErlang is a haskell library which consists on a parser and pretty-printer for the intermediate language used by Erlang.

The parser uses the Parsec library and the pretty-printer was modelled after the corresponding module of the haskell-src package. It also exposes a Syntax module which allows easy manipulation of terms.

It is able to parse and pretty print all of Core Erlang. Remaining work includes customizing the pretty printer and refining the syntax interface.

Syntax

module ::= module Atom [fnamei1 , ... , fnameik] attributes [attr1, ..., attrm] fundef1 ... fundefn end

attr ::= Atom = const

fundef ::= fname = fun

fname ::= Atom / Integer

const ::= lit | clist | ctuple | cmap

clist ::= [const1 | const2]

ctuple ::= {const1 , ..., constn}

cmap ::= ~{const1 => const2 , ..., constm => constn}~

lit ::= Atom | Integer | Float | Char | String | [ ]

fun ::= fun (var1, ..., varn) -> exprs

var ::= VariableName

exprs ::= expr | <expr1 , ..., exprn>

expr ::= var | fname | lit | fun

​            | [exprs1 | exprs2]

​            | {exprs1, ..., exprsn}

​            | ~{exprs1 => exprs2 , ..., exprsm => exprsn}~

​            | let vars = exprs1 in exprs2

​            | case exprs of clause1 · · · clausen end

​            | letrec fname1 = fun1 · · · fnamen = funn in exprs

​            | apply exprs0 (exprs1, . . ., exprsn)

​            | call exprs′1:exprs′2(exprs1, . . ., exprsn)

​            | primop Atom(exprs1, . . ., exprsn)

​            | receive clause1 · · · clausen after exprs1 -> exprs2

​            | try exprs1 of <var1, . . .varn> -> exprs2

​              catch <varn+1, . . .varn+m> -> exprs3

​            | do exprs1 exprs2

​            | catch exprs

vars ::= var | <var1, ..., varn>

clause ::= pats when exprs1 -> exprs2

pats ::= pat | <pat1, ..., patn>

pat ::= var | lit | var = pat | plist | ptuple | pmap

plist ::= [pat1 | pat2]

ptuple ::= {pat1, ..., patn}

pmap ::= ~{pkey1 := pat1, ..., pkeyn := patn}~

pkey ::= var | lit

License

BSD3

Authors

About

AST, parser, pretty-printer for Core Erlang source code.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Erlang 88.2%
  • Haskell 11.7%
  • Makefile 0.1%