Skip to content

Latest commit

 

History

History
38 lines (29 loc) · 2.53 KB

example_language1.md

File metadata and controls

38 lines (29 loc) · 2.53 KB

Example "language1"

Description

This is a general-purpose, statically typed programming language with the following features:

  • Structures (plain data stuctures without methods, implicitly defined assignment operator)
  • Interfaces
  • Classes (custom defined constructors, destructors, operators, methods, inheritance of classes and interfaces)
  • Free procedures and functions
  • Polymorphism through interface inheritance
  • Generic programming (generic classes and functions)
  • Lambdas as instantiation arguments of generic classes or functions
  • Exception handling with a fixed exception structure (an error code and an optional string)
  • Backend is LLVM IR

Project Specific Files

The project specific files of the test language language1 are located in examples/language1

  • grammar.g Grammar description in a kind of BNF with Lua function calls to the typesystem module writen in Lua as attributes.
  • llvmir.lua Format templates organized in structures for producing LLVM output.
  • llvmir_scalar.lua GENERATED FILE. Format templates organized in structures for the built-in basic first class scalar types.
  • scalar_types.txt Descriptions of the built-in basic first class scalar types.
  • typesystem.lua Implements the Lua function calls referenced in the grammar.

Example Source Files

  • fibo.prg using functions, procedures, constant string literal, and output via a C Library printf call.
  • tree.prg implementing a tree, demonstrating a recursively defined data structure.
  • pointer.prg using pointers to data and pointers to functions.
  • array.prg demonstrating the use of arrays.
  • class.prg demonstrating class and interface inheritance.
  • generic.prg using some generic programming stuff.
  • complex.prg implementing some calculations with complex numbers.
  • matrix.prg implementing a matrix class using generics and lambdas.
  • exception.prg testing exception handling, verified with Valgrind.