The Gorilla Programming Language

Overview

Gorilla

Gorilla Programming Language

Gorilla is a tiny, dynamically typed, multi-engine programming language

It has flexible syntax, a compiler, as well as an interpreter.

The minimized executable size is only about 1.6 MB!

Download the latest release

Play it Online


Credits:

Icon: Binx

Issues
  • Feature: Right-to-Left parsing for exponentiation operator

    Feature: Right-to-Left parsing for exponentiation operator

    Is your feature request related to a problem? Please describe.

    Parsing for the exponentiation operator (**) is currently left-to-right, when mathematically it should be right-to-left. This could cause unexpected behavior when someone is implementing an algorithm.

    What type of feature are you requesting?

    Syntax/Parsing Improvement

    Please provide some examples of what Gorilla should be like with your feature.

    Gorilla image JavaScript image Python image

    Why should Gorilla have this? Give 2 to 5 reasons.

    Parsing for the exponentiation operator (**) is currently left-to-right, when mathematically it should be right-to-left. This could cause unexpected behavior when someone is implementing an algorithm.

    opened by Samathingamajig 3
  • Feature: Multiline array declarations

    Feature: Multiline array declarations

    With many languages, multiline array declarations work, and is pretty much required for 2+ dimensional arrays to look pretty when writing the code.

    The code snippets below work

    let oneDimArray = [1, 3, 6]
    
    display(oneDimArray)
    
    let twoDimArray = [[1, 5, 8],[3, 7, 2],[9, 4, 6]]
    
    display(twoDimArray)
    

    but in the case of the 2 dimensional array, that looks really wonky and can get bad fast with increased length or increased dimensions.

    The code snippets below should work, but return errors:

    let oneDimArray = [
      1,
      3, 
      6
    ]
    
    display(oneDimArray)
    
     parser errors:
    	[Line 1] Invalid Syntax: unexpected '; or newline'
    	[Line 2] expected ], got INT instead
    	[Line 2] Invalid Syntax: Expected Newline or ';', got 'INT'
    	[Line 2] Invalid Syntax: Expected Newline or ';', got ','
    	[Line 2] Invalid Syntax: unexpected ','
    	[Line 3] Invalid Syntax: Expected Newline or ';', got ','
    	[Line 3] Invalid Syntax: unexpected ','
    	[Line 5] Invalid Syntax: unexpected ']'
    
    let twoDimArray = [
         [1, 5, 8],
         [3, 7, 2],
         [9, 4, 6]
     ]
    
    display(twoDimArray)
    
     parser errors:
    	[Line 1] Invalid Syntax: unexpected '; or newline'
    	[Line 2] expected ], got [ instead
    	[Line 2] expected ], got , instead
    	[Line 2] Invalid Syntax: Expected Newline or ';', got ','
    	[Line 2] Invalid Syntax: unexpected ','
    	[Line 2] Invalid Syntax: Expected Newline or ';', got 'INT'
    	[Line 2] Invalid Syntax: Expected Newline or ';', got ','
    	[Line 2] Invalid Syntax: unexpected ','
    	[Line 2] Invalid Syntax: Expected Newline or ';', got 'INT'
    	[Line 2] Invalid Syntax: Expected Newline or ';', got ']'
    	[Line 2] Invalid Syntax: unexpected ']'
    	[Line 2] Invalid Syntax: Expected Newline or ';', got ','
    	[Line 2] Invalid Syntax: unexpected ','
    	[Line 3] Invalid Syntax: Expected Newline or ';', got ','
    	[Line 3] Invalid Syntax: unexpected ','
    	[Line 5] Invalid Syntax: unexpected ']'
    
    

    While you're at it, I also would like to propose that the "trailing comma" rule is implemented
    The trailing comma rule in most languages mean that if you have an array, dict, object, list, etc. there can be a singular extra comma at the end, which is useful for reducing the numbers of lines that are changed when commiting code to something like git.

    enhancement 
    opened by Samathingamajig 3
  • Unexpected behaviour when doing operations between type String with type Integer

    Unexpected behaviour when doing operations between type String with type Integer

    When trying to do operations between a String and an Integer in this specific order Gorilla panics

    Example of comparison

    [0] >> "abc" == 10
    

    We expect to get false, but instead we get

    Gorilla 0.3
    [0]>> "abc" == 10
    panic: interface conversion: object.Object is *object.Integer, not *object.String
    
    goroutine 1 [running]:
    _/C_/Users/derek/Desktop/Code/Go_Projects/Gorilla/gorilla/eval.evalStringInfixExpression(0xc00000a10c, 0x2, 0xaadb20, 0xc000064540, 0xaada00, 0xc0000645a0, 0xc0000645a0, 0xc000064540)
            C:/Users/derek/Desktop/Code/Go Projects/Gorilla/gorilla/eval/eval.go:304 +0x5ce
    _/C_/Users/derek/Desktop/Code/Go_Projects/Gorilla/gorilla/eval.evalInfixExpression(0xc00000a10c, 0x2, 0xaadb20, 0xc000064540, 0xaada00, 0xc0000645a0, 0xc00003a0c0, 0x0)
            C:/Users/derek/Desktop/Code/Go Projects/Gorilla/gorilla/eval/eval.go:252 +0x7c5
    _/C_/Users/derek/Desktop/Code/Go_Projects/Gorilla/gorilla/eval.Eval(0xaac840, 0xc00003c0c0, 0xc00002e350, 0xaac840, 0xc00003c0c0)
            C:/Users/derek/Desktop/Code/Go Projects/Gorilla/gorilla/eval/eval.go:62 +0xe68
    _/C_/Users/derek/Desktop/Code/Go_Projects/Gorilla/gorilla/eval.Eval(0xaac6c0, 0xc00003a080, 0xc00002e350, 0xaac6c0, 0xc00003a080)
            C:/Users/derek/Desktop/Code/Go Projects/Gorilla/gorilla/eval/eval.go:37 +0xb38
    _/C_/Users/derek/Desktop/Code/Go_Projects/Gorilla/gorilla/eval.evalProgram(0xc000004520, 0xc00002e350, 0x1, 0x0)
            C:/Users/derek/Desktop/Code/Go Projects/Gorilla/gorilla/eval/eval.go:123 +0xc9
    _/C_/Users/derek/Desktop/Code/Go_Projects/Gorilla/gorilla/eval.Eval(0xaac940, 0xc000004520, 0xc00002e350, 0xc00000a100, 0xb)
            C:/Users/derek/Desktop/Code/Go Projects/Gorilla/gorilla/eval/eval.go:34 +0xc5
    _/C_/Users/derek/Desktop/Code/Go_Projects/Gorilla/gorilla/repl.Start(0xaac3e0, 0xc000006010, 0xaac400, 0xc000006018)
            C:/Users/derek/Desktop/Code/Go Projects/Gorilla/gorilla/repl/repl.go:40 +0x36c
    _/C_/Users/derek/Desktop/Code/Go_Projects/Gorilla/gorilla/gorilla.RunFile()
            C:/Users/derek/Desktop/Code/Go Projects/Gorilla/gorilla/gorilla/gorilla.go:23 +0x448
    main.main()
            C:/Users/derek/Desktop/Code/Go Projects/Gorilla/gorilla/main.go:8 +0x27
    

    Example of addition

    [0] >> "abc" + 10
    

    We expect to get a RuntimeError like this

     Runtime Error:
            [Line 1] type mismatch: STRING + INTEGER (When attempting to run 'abc + 10')
    

    But instead the program panics

    Gorilla 0.3
    [0]>> "abc" + 10
    panic: interface conversion: object.Object is *object.Integer, not *object.String
    
    goroutine 1 [running]:
    _/C_/Users/derek/Desktop/Code/Go_Projects/Gorilla/gorilla/eval.evalStringInfixExpression(0xc0000a20dc, 0x1, 0xaadb20, 0xc0000b6540, 0xaada00, 0xc0000b65a0, 0xc0000b65a0, 0xc0000b6540)
            C:/Users/derek/Desktop/Code/Go Projects/Gorilla/gorilla/eval/eval.go:304 +0x5ce
    _/C_/Users/derek/Desktop/Code/Go_Projects/Gorilla/gorilla/eval.evalInfixExpression(0xc0000a20dc, 0x1, 0xaadb20, 0xc0000b6540, 0xaada00, 0xc0000b65a0, 0xc0000d4080, 0x4)
            C:/Users/derek/Desktop/Code/Go Projects/Gorilla/gorilla/eval/eval.go:252 +0x7c5
    _/C_/Users/derek/Desktop/Code/Go_Projects/Gorilla/gorilla/eval.Eval(0xaac840, 0xc0000d0060, 0xc000088340, 0xaac840, 0xc0000d0060)
            C:/Users/derek/Desktop/Code/Go Projects/Gorilla/gorilla/eval/eval.go:62 +0xe68
    _/C_/Users/derek/Desktop/Code/Go_Projects/Gorilla/gorilla/eval.Eval(0xaac6c0, 0xc0000d4040, 0xc000088340, 0xaac6c0, 0xc0000d4040)
            C:/Users/derek/Desktop/Code/Go Projects/Gorilla/gorilla/eval/eval.go:37 +0xb38
    _/C_/Users/derek/Desktop/Code/Go_Projects/Gorilla/gorilla/eval.evalProgram(0xc0000984a0, 0xc000088340, 0x1, 0x0)
            C:/Users/derek/Desktop/Code/Go Projects/Gorilla/gorilla/eval/eval.go:123 +0xc9
    _/C_/Users/derek/Desktop/Code/Go_Projects/Gorilla/gorilla/eval.Eval(0xaac940, 0xc0000984a0, 0xc000088340, 0xc0000a20d0, 0xa)
            C:/Users/derek/Desktop/Code/Go Projects/Gorilla/gorilla/eval/eval.go:34 +0xc5
    _/C_/Users/derek/Desktop/Code/Go_Projects/Gorilla/gorilla/repl.Start(0xaac3e0, 0xc0000cc000, 0xaac400, 0xc0000cc008)
            C:/Users/derek/Desktop/Code/Go Projects/Gorilla/gorilla/repl/repl.go:40 +0x36c
    _/C_/Users/derek/Desktop/Code/Go_Projects/Gorilla/gorilla/gorilla.RunFile()
            C:/Users/derek/Desktop/Code/Go Projects/Gorilla/gorilla/gorilla/gorilla.go:23 +0x448
    main.main()
            C:/Users/derek/Desktop/Code/Go Projects/Gorilla/gorilla/main.go:8 +0x27
    

    The first one is most likely a bug, because comparisons between different type should return true or false, as they do when you put first the Integer and then the String.

    Gorilla 0.3
    [0]>> 10 == "abc"
    false
    

    On the other hand a binary operation between different types can be an error but this one is probably a bug. The reason being that if you try and do the same operation but letting the left expression be an Integer and the right one be a String you indeed get a RuntimeError and the program doesn't panic.

    Gorilla 0.3
    [0]>> 10 + "abc"
     Runtime Error:
            [Line 1] type mismatch: INTEGER + STRING (When attempting to run '10 + abc')
    

    All operations except multiplication where the left expression is a String and the right one is an Integer panic. By operations I mean Add (+), Substract (-), Multiply (*), Divide (/), Less Than (<), Greater Than (>), Less Than or Equal (<=), Greater Than or Equal (>=), Equal (==) and Not Equal (!=)

    bug help wanted 
    opened by lautiux 3
  • Feature: Disregard newlines between function header and body

    Feature: Disregard newlines between function header and body

    I can't use the {} brackets in a new line; e.g.

    func hello (any){
    println("hello" + any")
    }
    

    ^this works, but when i use:

    func hello (any)
    {
    println(any)
    }
    

    it returns an error.

    enhancement 
    opened by Kensei-01 2
  • Allocations and Garbage collector; Use reference/pointer for all gorilla objects.

    Allocations and Garbage collector; Use reference/pointer for all gorilla objects.

    Allocations and Garbage collector; Use reference/pointer for all gorilla objects. Variables should point to a pointer instead of cloned object. Vector should contain pointers as well. Probably need a vm-level allocator and pass it through functions. Not sure how to do the gc though.

    enhancement 
    opened by SnowballSH 1
  • Extremely slow on if/else statements (Jump, JumpIfFalse)

    Extremely slow on if/else statements (Jump, JumpIfFalse)

    In Gorilla 1.0, Jump and JumpIfFalse instructions work extremely slow. A simple program adding a single if statement slows down by 2 seconds (average 0.2 second per loop). I currently have no idea how to fix it.

    bug enhancement help wanted 
    opened by SnowballSH 1
  • Add error & return checking for while loop

    Add error & return checking for while loop

    Allows errors to be caught when there are errors inside of a while loop.

    If there is an explicit return value statement, that stops the loop too

    All tests pass (I didn't make any new tests) image

    opened by Samathingamajig 1
  • Add simple string indexing (and added string indexing test cases)

    Add simple string indexing (and added string indexing test cases)

    Title really says it all.

    Just like arrays have indexing, strings do too now.

    display("Expects 'e'")
    display("Hello"[1]) # Expects "e"
    
    display("Expects 'r'")
    display("Wowzers"[5]) # Expects "r"
    
    display("Expects 'd'")
    let str = "Lorem ipsum dolor sit amet.";
    let str = "padding" + str + "padding";
    display(str[19]) # Expects "d"
    

    Output: image

    Continues to keep old tests working, and passes my tests image

    Once I found where I needed to modify stuff, Go was a relatively ok language to code in. Most of my code was just copy/pasting and modifying to what I needed to modify to get things working. I did have a lot of trouble with this part:

    retString := object.NewString(string(stringObject.Value[idx]), stringObject.Line())
    return retString // stringObject.Value[idx]
    

    because I don't think I should be creating a NewString object, but it at least works I guess.

    Note:

    This PR also adds *.exe to the .gitignore file. If you don't want that change, remove that part.

    opened by Samathingamajig 1
  • Add .toStr() method to all data types, except booleans & null

    Add .toStr() method to all data types, except booleans & null

    The problem with this is that booleans & null don't have a .toStr() property, and I don't know how to add them, if that's even possible. Another way I thought of doing this is to maybe make a str(anyObject) function, so let me know if that'd be the preferred way. I just added .toStr() since that was the one already used by ints

    Passes all tests, as expected image

    opened by Samathingamajig 0
Releases(v1.0.0-early-alpha)
  • v1.0.0-early-alpha(Apr 1, 2021)

    The core of Gorilla is completed. Attached binaries are for windows x64 and Ubuntu. Other linux distributions might encounter bugs with the repl.

    This includes:

    • 100% test coverage
    • 80% - 90% doc coverage (except ast and tokens)
    • Fully working CLI
    • Fully working VM and Compiler

    Next steps till Alpha release:

    • Booleans
    • Comparisons (returns boolean)
    • Loops
    • Instance access (x.y)
    • More builtin methods

    Probable steps till Beta release:

    • Functions
    • Libraries
    Source code(tar.gz)
    Source code(zip)
    Gorilla(2.02 MB)
    Gorilla.exe(2.11 MB)
  • 0.4.0.1(Feb 11, 2021)

  • 0.4.0-beta(Feb 8, 2021)

    Final beta version of Gorilla 0.4.0. Here is what I added:

    • More builtins
    • Flexible syntax (less newline restrictions)
    • Unordered hash maps
    • Floats and builtins
    • Flow control (break, next aka continue)
    • Dynamic library building - will be used in Gorilla 0.4.1
    • Less CPU/Memory usage (about 40% less)

    Cons:

    • 20% - 40% slower because of dynamic objects
    • hash value is limited so there might me duplications... (but probablility is 1/18446744073709551615 lol)

    Will be writing markdown docs now!

    Source code(tar.gz)
    Source code(zip)
    Gorilla.exe(4.41 MB)
  • 0.4.0(Feb 8, 2021)

    Major release of Gorilla 0.4.0

    After fixing several bugs and adding several features, I am here announcing Gorilla 0.4.0!

    Changes since Gorilla 0.4.0-beta:

    • More flexible syntax (http server, math, random)
    • Modules
    • Better float support

    Note: Gorilla.exe is for windows 10 only

    Source code(tar.gz)
    Source code(zip)
    Gorilla.exe(8.76 MB)
  • v0.4.0-alpha(Feb 6, 2021)

  • 0.3.3(Jan 29, 2021)

  • 0.3.2(Jan 21, 2021)

    Major release of gorilla

    Added features:

    • Merged #3
    • BETA version of compiling. This means there might be bugs. However, using the compiler makes a program 4x faster!
    • Execute compiling by adding -c tag before file name !
    • Minor bug fixes
    • In-built array object syntax: [1, 2, "str", true]
    • Array push feature syntax: arr <- element
    • Modulo operator 5 % 2
    • and more!

    Example for this update:

    let arr = [0, 1, 7777777]
    display(5 % (arr <- 2)[3] == "1   ".strip().toInt())
    

    will output true

    P.S. I am currently unable to get the linux binary so I only attached the windows one. P.P.S. Playground is still available if you are using linux or mac but you don't have go. Have fun!

    Next step: doc/website

    Source code(tar.gz)
    Source code(zip)
    gorilla.exe(2.75 MB)
  • 0.3.1(Jan 13, 2021)

  • 0.3(Jan 12, 2021)

    Gorilla 0.3 is out now with tons of new features!

    • Attribute accessing
      • Syntax: <Expression>.<Name>
      • Example: "123".toInt()
    • Builtin functions
      • All current builtin methods:
        • display(*args: Any) displays expressions to stdout.
        • len(arg: String) calls arg._len().
        • String.strip() trims whitespace for a string.
        • String._len() secret method, accesible, gets the length of string.
        • String.toInt() attempt to parse string to Integer. If fails, an error is raised.
        • Int.toStr() converts an Integer to String.
    • Syntax to notice:
      • func <Name> (*args) {<Statements>} to make a top-level function.
      • let <Name> = <Expression> to assign value to variable
    Source code(tar.gz)
    Source code(zip)
    gorilla.exe(2.58 MB)
  • 0.2.1.1(Jan 7, 2021)

    Minor fix on string display

    features added:

    • Faster evaluation
    • String
    • Top-level functions
    • Built-in functions
      • string len()
      • display() (print)

    features adding soon:

    • Get started guide
    • Syntax doc

    note:

    • the largest integer you can have in Gorilla is int64
    • string has no size limitation since it uses less bytes
    • string + string is concatation, string * int is repeatition
    • unicode string is supported, not unicode variable names are not

    features in the next update:

    • array
    • comments!!
    • more syntax
    Source code(tar.gz)
    Source code(zip)
    gorilla.exe(2.54 MB)
  • 0.2.1(Jan 7, 2021)

    Major evaluation fix: null

    features added:

    • Faster evaluation
    • String
    • Top-level functions
    • Built-in functions
      • string len()
      • display() (print)

    features adding soon:

    • Get started guide
    • Syntax doc

    note:

    • the largest integer you can have in Gorilla is int64
    • string has no size limitation since it uses less bytes
    • string + string is concatation, string * int is repeatition
    • unicode string is supported, not unicode variable names are not

    features in the next update:

    • array
    • comments!!
    • more syntax
    Source code(tar.gz)
    Source code(zip)
    gorilla.exe(2.54 MB)
  • 0.2(Jan 7, 2021)

  • 0.1(Jan 4, 2021)

Owner
A student programmer
null
Advent of Code is an Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language you like.

Advent of Code 2021 Advent of Code is an Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved

Kemal Ogun Isik 0 Dec 2, 2021
Zach Howell 0 Jan 4, 2022
Unit tests generator for Go programming language

GoUnit GoUnit is a commandline tool that generates tests stubs based on source function or method signature. There are plugins for Vim Emacs Atom Subl

Max Chechel 62 Jul 8, 2022
FreeSWITCH Event Socket library for the Go programming language.

eventsocket FreeSWITCH Event Socket library for the Go programming language. It supports both inbound and outbound event socket connections, acting ei

Alexandre Fiori 107 Aug 2, 2022
Simple interface to libmagic for Go Programming Language

File Magic in Go Introduction Provides simple interface to libmagic for Go Programming Language. Table of Contents Contributing Versioning Author Copy

Krzysztof Wilczyński 12 Dec 22, 2021
Elastic is an Elasticsearch client for the Go programming language.

Elastic is an Elasticsearch client for the Go programming language.

Oliver Eilhard 7k Aug 8, 2022
👩🏼‍💻A simple compiled programming language

The language is written in Go and the target language is C. The built-in library is written in C too

paco 26 Jul 22, 2022
Lithia is an experimental functional programming language with an implicit but strong and dynamic type system.

Lithia is an experimental functional programming language with an implicit but strong and dynamic type system. Lithia is designed around a few core concepts in mind all language features contribute to.

Valentin Knabel 6 Jun 14, 2022
accessor methods generator for Go programming language

accessory accessory is an accessor generator for Go programming language. What is accessory? Accessory is a tool that generates accessor methods from

masaushi 5 Jul 19, 2022
Http web frame with Go Programming Language

Http web frame with Go Programming Language

jk 0 Oct 17, 2021
A modern programming language written in Golang.

MangoScript A modern programming language written in Golang. Here is what I want MangoScript to look like: struct Rectangle { width: number he

PlebusSupremus1234 3 Nov 12, 2021
A stack oriented esoteric programming language inspired by poetry and forth

paperStack A stack oriented esoteric programming language inspired by poetry and forth What is paperStack A stack oriented language An esoteric progra

null 0 Nov 14, 2021
Oak is an expressive, dynamically typed programming language

Oak ?? Oak is an expressive, dynamically typed programming language. It takes the best parts of my experience with Ink, and adds what I missed and rem

Linus Lee 166 Jul 31, 2022
Besten programming language

Besten What holds this repository? Besten Lexer Besten Parser Besten Interpreter Besten Module Loader Besten Lexer Located in ./internal/lexer A set o

Alberto Elorza 2 Jun 13, 2022
🎅 A programming language for Advent of Code.

?? Adventlang My blog post: Designing a Programming Language for Advent of Code A strongly typed but highly dynamic programming language interpreter w

Andrew Healey 27 Mar 2, 2022
An experimental programming language.

crank-lang An experimental & interpreted programming language written in Go. Features C like syntax Written in Golang Interpreted Statically Typed Dis

inmicro 2 Dec 6, 2021
Gec is a minimal stack-based programming language

Gec is a minimal stack-based programming language

aiocat 1 May 22, 2022
Functional programming library for Go including a lazy list implementation and some of the most usual functions.

functional A functional programming library including a lazy list implementation and some of the most usual functions. import FP "github.com/tcard/fun

Toni Cárdenas 31 May 21, 2022
Flow-based and dataflow programming library for Go (golang)

GoFlow - Dataflow and Flow-based programming library for Go (golang) Status of this branch (WIP) Warning: you are currently on v1 branch of GoFlow. v1

Vladimir Sibirov 1.4k Jul 30, 2022