GithubHelp home page GithubHelp logo

chill-language / icm Goto Github PK

View Code? Open in Web Editor NEW
7.0 3.0 2.0 498 KB

The Interpreter of The Chill 0.3 Programming Language

License: Apache License 2.0

C++ 95.41% CMake 0.17% C 4.42%
chill icm interpreter language

icm's Introduction

ICM (Building)

The Interpreter of The Chill 0.3 Programming Language

Now the "Hello World!" program can be run!

ICM 0.3
> (println (+ "Hello " "World!"))
Hello World!
=> ["Hello World!"]

How To Build

You should ensure that your compiler support C++14.

If you have cmake & gcc, you can input these commands:

mkdir build
cd build
cmake ..
make

If you have MSVC (Visual Studio), you can also create a project to build these files.

How To Run

Command Mode:

Just run the program after you have built it.

File Mode:

Use 'icm run.chl'(Windows) or './icm run.chl'(Linux) after you have built it. 'run.chl' is a source file to test the program.

Grammar

Call Function : (FunctionName Parameters...)

(+ 5 6)       ; Same as 5 + 6, result = 11
(+ 5 (- 7 2)) ; Same as 5 + (7 - 2), result = 10
(f x)         ; Same as f(x)
(g (f x) y)   ; Same as g(f(x), y)

Function is an object in the Chill Language.
If 'a' is a function, or it is a variable with a value of function, using '(a ...)' to call it, use 'a' to get it self.

; Example :
(defunc a [n] (+ n 1)) ; define a function named 'a', with an argument named 'n', to return the value of the expression '(+ n 1)'
(defunc b [n] (- n 2))
(defunc add_func [fa fb n] (+ (fa n) (fb n)))
(add_func a b n)

; Same As :
(defunc add_func [n] (+ (+ n 1) (- n 2)))
(add_func n)

'call' is a function to call function.

(call + 5 6)     ; Same As (+ 5 6)
(call (disp [+]) 5 6) ; Same As ((disp [+]) + 5 6), (+ 5 6)

Get List : use 'list' to get a list object.

e.g. (list 1 2 3 5)
'[...]' is same as '(list ...)'.
e.g. [1 2 3 5] ; same as (list 1 2 3 5)
'disp' is the anti-function of 'list'.

(print 5 6 7)          ; 567
; list : Var* -> List
(print [5 6 7])        ; [5 6 7]
; disp : List -> Var*
(print (disp [5 6 7])) ; 567

Assign : (let/ref/set AssignVars... AssignValue)

Assign

'cpy' can provide its value's copy.

(let a [1 2 3])
(let b a)        ; b = [1 2 3]
(let c (cpy a))  ; c = [1 2 3], Same as (cpy b a)
(set (at a 0) 5) ; a = [5 2 3]

(p a) ; [5 2 3]
(p b) ; [5 2 3]
(p c) ; [1 2 3]

icm's People

Contributors

chillmagic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

mmyjona zhusl

icm's Issues

在linux下编译的错误!!!

/home/lxd/ICM/source/runtime/deffunc.cpp: In lambda function:
/home/lxd/ICM/source/runtime/deffunc.cpp:285:38: error: converting to ‘const DataList {aka const Common::lightlist<ICM::Object*>}’ from initializer list would use explicit constructor ‘Common::lightlist<T>::lightlist(const std::initializer_list<_Tp>&) [with T = ICM::Object*]’
      r = rf.call({ a.get(), b.get() });

在修改了lightlist.h的构造函数的explicit后,虽然编译成功了。但是defunc不能正常工作!!!

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.