{"id":19297317,"url":"https://github.com/bhimsen92/YAIL","last_synced_at":"2025-04-22T09:30:41.244Z","repository":{"id":6893351,"uuid":"8142985","full_name":"bhimsen92/YAIL","owner":"bhimsen92","description":"A Functional Language Compiler for Multi Core Architecture","archived":false,"fork":false,"pushed_at":"2013-05-16T19:57:52.000Z","size":9282,"stargazers_count":25,"open_issues_count":1,"forks_count":9,"subscribers_count":13,"default_branch":"master","last_synced_at":"2024-11-09T23:02:28.533Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"caspark/ansible-factorio","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bhimsen92.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-02-11T17:48:16.000Z","updated_at":"2023-04-16T17:54:39.000Z","dependencies_parsed_at":"2022-07-28T22:49:37.537Z","dependency_job_id":null,"html_url":"https://github.com/bhimsen92/YAIL","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bhimsen92%2FYAIL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bhimsen92%2FYAIL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bhimsen92%2FYAIL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bhimsen92%2FYAIL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bhimsen92","download_url":"https://codeload.github.com/bhimsen92/YAIL/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250214984,"owners_count":21393705,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T23:01:51.418Z","updated_at":"2025-04-22T09:30:39.813Z","avatar_url":"https://github.com/bhimsen92.png","language":"C","funding_links":[],"categories":["C"],"sub_categories":[],"readme":"# YAIL : Yet Another Interpreted Language\nA Functional Language Interpreter.\n\n# What Do You Need To Build It ?\n1. flex[lex] tool\n2. bison[yacc] tool\n3. g++ compiler[latest version will be good]\n4. Linux OS.\n\n# How To Build\n1. Download zip file from github.\n2. Unzip it into any directory.\n3. Go to YAIL-[master]/lib folder\n4. execute \u003cb\u003emake\u003c/b\u003e command. This will create bnK-lang executable in the \u003cb\u003elib\u003c/b\u003e directory.\n5. Then go to \u003cb\u003esamples\u003c/b\u003e folder which contains some simple programs.\n6. Then execute the following command: \u003cstrong\u003e../lib/bnK-lang \u0026lt; file.yail [present in the \u003cb\u003esamples\u003c/b\u003e directory.\u003c/strong\u003e]\n\n\n# Why I built It ?\n1. To learn compiler design.\n2. To understand how computer languages are designed and what it takes to build them.\n3. To have experience with writing large code base and learn how to maintain it.\n4. And finally to have fun. It`s really a humbling experience to see writing a simple program in your own language and see it executing \n   on your own machine.\n\n\n# What it can do\n1. It is typed.\n2. Supports basic arithmatic operations.\n3. Supports basic types like Integers, Float, String, Function and Arrays[only for Integers and Double]\n4. Supports the creation of functions and nested functions.\n5. Supports Closure and Currying.\n6. Supports creation of Threads.\n\n# How to use it\n\n## Defining Variables\n\nCreating variables in \u003ci\u003e\u003cb\u003eyail\u003c/b\u003e\u003c/i\u003e language is similar to \u003ci\u003e\u003cb\u003eC or Java\u003c/b\u003e\u003c/i\u003e. First you need to specify the type and then\nthe name of the variable. Since it is a functional language, all variables that you define must be initialized.\n\n### Example:\n\n    Int num = 12; # statements must end with semicoln.\n    # or\n    Double d = 12.34; # To make value double, you need to write \".\" followed by some number.\n    # or\n    String str = \"Hello world\";\n    # or\n    Int[] num = [1, 2, 3, 4];\n    # or\n    Double[] num = [1.3, 2.3];\n    # or\n    Bool flag = false;\n    \nThere is no restriction on creation of variables, you can create them where ever you want and whenever you want.\n\nMultiple assignments are not allowed. So following code snippet will through an error and is in accordance with Functional language.\n\n    Int a = 12;\n    a = 34; # error\n\n\n## Making Decisions\nYou can control the flow of your program using good old if, else or elif structure. As in \u003ci\u003e\u003cb\u003eJava\u003c/b\u003e\u003c/i\u003e the coditional\nexpression must result in boolean value otherwise error will be thrown.\n\n### if Example:\n\n    Int a = 12, b = 10;\n    if(a \u003e b){\n      print(\"a is grater\\n\");\n    }\n    else{\n      print(\"b is greater\\n\");\n    }\n\u003cb\u003eelse\u003c/b\u003e block is compulsory whenever you write \u003cb\u003eif\u003c/b\u003e or \u003cb\u003eelif\u003c/b\u003e.\n\n### elif Example:\n\n    Int a = 10, b = 23, c = 25;\n    if(a \u003e b){\n      if(a \u003e c){\n        print(\"a is greater\\n\");\n      }\n      else{\n        print(\"c is greater\\n\");\n      }\n    }\n    elif(b \u003e c){\n      print(\"b is greater\\n\");\n    }\n    else{\n      print(\"c is greater\\n\");\n    }\n\n# Arrays\n\u003ci\u003e\u003cb\u003eyail\u003c/b\u003e\u003c/i\u003e has only one container object, Arrays. In this language arrays are fixed length and homogeneous, meaning\nthey contain values of the specified type. \n\nArrays support following operations:\n\n1. Indexing\n2. Concatenation\n3. Slicing\n\n### Array examples\n\n    # array creation\n    Int[] a = [1, 2, 3, 4, 5];\n    \n    # concatenation\n    Int[] b = a + [123, 34];\n    \n    # slicing\n    Int[] c = b[1:4];\n\n\n# Creating Functions\nIn \u003ci\u003e\u003cb\u003eyail\u003c/b\u003e\u003c/i\u003e functions are basic way of creating abstractions. Function block are created using \u003ci\u003efunction\u003c/i\u003e keyword,\nfollowed by \u003ci\u003ename\u003c/i\u003e of the function, then optional arguments and the return type followed by statements which you want to execute \nonce the function is called.\n### syntax for creating a function.\n\n    function funct_name([Type var,[Type var...]): ReturnType{\n         # list of statements.\n    }\n\n### Some Examples\n\n    # finding square.\n    function square(Int n):Int{\n        return n * n;\n    }\n\n    # finding factorial\n    function fact(Int n):Int{\n       if(n == 0)\n         return 1;\n       else\n         return n * fact(n - 1);\n    }\n    \n    # iterating through an array.\n    function printArray(Int[] arr):Nothing{\n      if(arr.length \u003e 0){\n         print(arr[0], \" \");\n         printArray(arr[1:]);\n      }\n      else{\n         print(\"\\n\");\n      }\n    }\n    \n    # simple map implementation.\n    function map(Int[] arr, Int index, Function f):Int[]{\n      if(index \u003c arr.length){\n         return [f(arr[index])] + map(arr, index + 1, f);\n      }\n      else{\n         return [];\n      }\n    }\n\n### Calling syntax for functions\n    \n    funct_name([arg,[arg..]]);\n\n\n# Creating Nested Functions and Closure\n\u003ci\u003e\u003cb\u003eyail\u003c/b\u003e\u003c/i\u003e supports nesting functions within function and supports closure to\n\n### Nested function example:\n\n    function outer():Nothing{\n      function inner():Nothing{\n         print(\"Hello world\\n\");\n      }\n      inner();\n    }\n    outer();\n\n### Closure example:\n\n    function nC(Int n):Function{\n      Int factN = fact(n);\n      function Cr(Int r):Int{\n         return factN/(fact(n - r) * fact(r));\n      }\n      return Cr;\n    }\n    \n    Function _5c = nC(5);\n    print(\"5C2: \", _5c(2));\n\n\n# Currying\nCurrying is a technique in which a function is called with few parameters then it officially takes. After this \u003ci\u003epartial\u003c/i\u003e\napplication, a new Function object is returned which you can use it to pass left over arguments so that the function finally gets\ncalled.\n\n### currying example:\n\n    function addThreeNumbers(Int a, Int b, Int c):Int{\n         return a + b + c;\n    }\n    \n    Function add1 = addThreeNumbers(1); # new function object gets returned which is ready to take 'b' and 'c'.\n    Function add5 = add1(5);\n    Int result = add5(10); # result = 16\n    print(\"Result: \", result);\n    \nThe samples directory contains a quicksort example, which uses currying concept.\n\n# What Needs To Be Done Yet\nLots of things needs to be implemented in this project but i believe following are really important which i want to concentrate\non.\n\n1. Implementing error module.[right now, if you get any error, interpreter just exits or a segmentation fault is thrown]\n2. Thread scheduling.\n3. Testing.\n\nI am still working on this project. Comments are really appreciated.\n\nFollowing People helped me a lot during my project.\n\n1. Ajey Bharadwaj A\n\n2. Gourav H Dhelaria \n\n3. Prof. N S Kumar [our Project Guide]\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbhimsen92%2FYAIL","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbhimsen92%2FYAIL","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbhimsen92%2FYAIL/lists"}