Giter Site home page Giter Site logo

tokamak's Introduction

Build Status

Tokamak

Advanced Fusion Reactor

Tokamak DSL

Tokamak DSL is a Domain Specific Language for .NET, written with FParsec parser combinator library.

Purpose

Tokamak can be embedded in .NET / mono applications (using .NET framework ~4.0+).

Evaluation

Expressions are evaluated right to left, with no operator precedence. Parentheses are used to evaluate subexpressions before the outer expression.

DataTypes

  • Integer - corresponds to int64
  • Floating - corresponds to double
  • Literal - corresponds to string
  • Bool - bool
  • Array - This is an array of expressions, which may be datatypes or other expressions that can be evaluated to a datatype.

Functions

Functions are declared using function keyword followed by the function name, the parameters, the function body, and is terminated using the end keyword.

example

function fib(n)
  if n <= 1 then 1
  else
    n * fib(n-1)
  end
end

Array creation

Array declarations are simple:

myArray = 0$10 

This will create an array [0,1,...,9]. The contents of the array can be modified arbitrarily:

myArray[0] = 5.5

Controls

Tokamak has while-loops and for-loops, as well as if-elif-else blocks.

while loops

a = 0
ctr = "a"
while a < 10 do 
  a = a + 1
  ctr = ctr+"a" 
end

will produce the string aaaaaaaaaa.

for loops

function iseven(n) (n%2) = 0 end

arr = 0$100

for i in 0$100 do
  arr[i] = iseven(i)
end

arr

if-elseif-else control

a = 0$100
m0 = 0
m1 = 0
m2 = 0
for i in a do
  if 0 = i%3 then
    m0 = m0 + 1
  elseif 1 = i%3 then
    m1 = m1 + 1
  else m2 = m2 + 1
  end
end

tokamak's People

Contributors

jonghough avatar

Watchers

 avatar  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.