Home

From informl
Jump to: navigation, search

The Informl language is a cross-platform DSL for implementing algorithms that operate on abstract syntax trees.

Informl is a programming language meant to give users the ability to perform operations on “functional-like” abstract data types in the familiar procedural paradigm. The language supports and compiles into three languages: JavaScript (both browser and Node environments), PHP, and Python 3.

Install

Informl requires Haskell and the Haskell library Parsec to be installed. To run Informl scripts, a JavaScript, PHP or Python environment is needed. Install by downloading the repository on GitHub and running the release.sh file.

Now compile any '.iml' file to JavaScript, PHP, or Python using '-js', '-php', or '-py' flags respectively in the shell.

   >>informl -js "path/to/File.iml"

How To Use Informl

Platforms

Basic Syntax

Pattern Matching

Advanced Syntax

Example Code

   module TreeSearch
       # does a depth-first search on a tree defined by ADTs
       # then returns a pattern consisting of 
       private dfs(tree,isSuper,key)
           get tree
               Node(left,right)
                   #searches left side first
                   if dfs(left,isSuper,key) is Found(depth,color,value)
                       return Found(depth+1,color,value)
                   #then the right
                   if dfs(right,isSuper,key) is Found(depth,color,value)
                       return Found(depth+1,color,value)
                   #If it cannot find in either recursive call
                   #it returns a NotFound pattern
                   return NotFound
               Leaf(Black(k,value))
                   if k == key
                       return Found(0,IsBlack,value)
                   else
                       return NotFound
               Leaf(White(k,value))
                   if k == key
                       return Found(0,IsWhite,value)
                   else
                       return NotFound
               Blocked(a)
                   if isSuper
                       return dfs(a,isSuper,key)
                   return NotFound
       # searches tree and returns the value
       function findValue(tree,key)
           local search = dfs(tree,false,key)
           return value if search is Found(d,c,value) else SearchFailed