Code Monkey home page Code Monkey logo

cygni's Introduction

Cygni

A lightweight, object-oriented script interpreter implemented in C#.

The Cygni language is inspired by many script languages, such as Lua, Python, etc.

Screen shots

image

Installation

Here are two options. The first option is to download the compiled interpreter.

  • Download the program from

Cygni_CLI

  • If you are using windows, just double click the Cygni_CLI.exe.

  • If you are using Linux, you need to install mono environment and input "mono Cygni_CLI.exe" in the terminal.

The second option is to compile one by yourself.

  • Download the Cygni Core from

Cygni

  • Import the Cygni.dll to your project.

The API is very easy. Have a look at this example.

using System;
using Cygni;

namespace Cygni_CLI
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			Engine engine = Engine.CreateInstance ();
			engine.ExecuteInConsole ();
		}
	}
}

Some tutorial examples

For more information, see the short reference in Cygni-short-ref

Factorial

def fact(n) {
	if n == 0 {
		return 1
	} else {
		return n * fact(n - 1)
	}
}
print(fact(10)) # 3628800

Calculate the sum of a list

def sum(myList) {
	var s = 0
	for v in myList {
		s = s + v
	}
	return s
}
print(sum([1,2,3,4,5])) # 15

Define a class and a derived class

class Person {

	var name, age

	def __init__(name, age) {
		this.name = name
		this.age = age
	}

	def say() {
		printf("{0} is a person.", this.name)
	}

}

class Employee: Person {

	var salary = 3000

	def say() {
		printf("{0} is an employee.", this.name)
	}

}

alice = Person("Alice", 35)
john = Employee("John", 40)

alice.say()
john.say()

print("John's salary : " & john.salary)

cygni's People

Watchers

 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.