Giter Site home page Giter Site logo

aj-language's Introduction

*Aj* language interpreter

Aj is imperative programming language created by me during bechelor CS studies. It consists of several elements from functional and object-oriented languages. I tried to choose my favourite things from few languages and than mix them in my creation. What's more I rejected some frustrating constructions and that's how aj was created. It takes some syntax from c++ and java, but at the same time function defining looks familiar to haskell. Repositorium files include:

  • calc.cf - grammar in bnfc form
  • Abscalc.hs - parsing tree's data structers
  • ErrM.hs - error handling
  • Error.hs - own implementation of error handling
  • Lexcalc.hs - lexer internals
  • Parcalc.hs - parsing to LR tree
  • Skelcalc.hs - just skeletons of functions used by interpreter
  • Core.hs - main and commonly used interpreter's structers
  • Declarations.hs - funtions connected with definig things in aj
  • program.hs - kind of main file. Connects few modules
  • Storable.hs - everything what is connected with values that can be stored (int, string etc...).
  • Interpreter.hs - expressions + statements
  • TypeChekcer.hs - module does static code analisis

Implemented features:

  • variables, assingments
  • if [ else and elseif], switch
  • loop - only one loop construction, that can easily act like while and for
  • arithmetic
  • comparing
  • functions (multiple parametrs to return] and procedures
  • recursion
  • IO operation: print
  • variable overriding and vars scopes
  • static typic
  • handling run time errors [ i.e. dividing by 0, out of range array]
  • records - simple classess
  • arrays / lists [multidimensional]
  • passing functions as functions arguments (even lambda functions)
  • anonymous functions
  • ested functions with static binding

Features

Typy

  • int - range like haskell integer
  • true / false values
  • text - one type for char / string
  • double - real numbers
  • own types ...
  • arrays

Implicit conversions between multiple types are implemented (where this makes sense). For example, the empty text goes to false, The text compared to the number reflects as its length.

Conditionals

if

Possible variants with multiple elseifs, with else, without else, etc.if one line statemntthen without brackets. Conditions are impinging implicitly on bool
switch
Traditional semantics of the switch, except that instead of default is else, after the switch. Any possible object that can be compared, can appear as a switch argument (not only numbers as in other languages)

Loop

Loop - one loop instead while and for. Semantics is more like for, but you can cause it to work like a while :). We can define variables in the loop header, possible multiple chapters (use |). The semantics of variables are more interesting, because those declared in the middle of the loop are created only in first step. As a condition may be passed any variable, not necessarily declared in the loop.

Functions

We can pass both function and normal variables to functions. Passing only by value is possible - so that it was not side effects. We can return many values but not functions. There are no static binding in functions. Every function declaration generates a type with the same name - it can be assigned values ​​returned by the function. If we return one value - Simple return, without having to assign to a function type.

Data Structures

arrays

Any number of dimensions and any type of arrays, an array can also occur in records.

records

Only variable fields are possible, you cannot add functions to classes at this time. Possible to pass objects to functions, creating arrays from them, or compare objects of the same type.

IO

print

Allows you to print almost any type, listing your own type (object) prints a list of values assigned to the object.

Notes

My grammar is long - it results from a lot of syntactic sugar. Assignment prescribes value, not pointer, but the construction of the environment appropriately allows you to assign indicators as well.

Checkout examples dirs

Compiling

Just type make in main folder

aj-language's People

Contributors

michocio avatar

Watchers

 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.