Interpreter for Swift-like language Swifty.
I decied to write two versions of this language to ilustrate different types of variables binding - dynamic and static. Core features of the language are identical. Repository is divided into two branches:
- Dynamic binding
- Static binding
Both containing:
- Grammar file Swifty.cf with language grammar for BNF Converter (bnfc)
- Interpreter implementation files generated with bnfc, EvalSwifty.hs with evaluation functions, TypeChecker.hs with type checker code.
- Docs directory:
- Language description, grammar etc in Swifty.pdf (generated by bnfc)
- Swifty.tex generated with bnfc
- Examples directory:
- Good directory with examples of working code in Swifty
- Bad directory with examples of typical error (syntax, runtime, type)
Swifty is interpreted, strongly typed programming language. Types of the variables are inferred by interpreter. Variables are dynamically/statically binded. Syntax of the language is derived from Apple's programming language Swifty.
- Basic
- Integers (int)
- Boolean (bool)
- Complex
- Arrays
- Structures
- Tuples
- Boolean expressions: ||, &&, ==, !=
- Arithmetic expressions: +,-,*,/ (integer division)
- Unary expressions: -, !
- Block
- Functions and procedures
- Variables, arrays, structs
- Assignment
- if, if-else
- while loop, foreach
- return
Code of the interpreter is written in Haskell. Parser and lexer were generated by BNF Converter. Evaluation functions are written in Continuation Passing Style, type checker is written with use of Monad State.