All Projects → pandeykartikey → Goto

pandeykartikey / Goto

Licence: mit
Goto is an interpreted programming language written in go.

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects
scripting
82 projects

Projects that are alternatives of or similar to Goto

ol
Otus Lisp (Ol in short) is a purely* functional dialect of Lisp.
Stars: ✭ 157 (+98.73%)
Mutual labels:  interpreter, repl
lambda-dti
Interpreter of the ITGL with dynamic type inference
Stars: ✭ 18 (-77.22%)
Mutual labels:  interpreter, repl
lambda
lambda calculus interpreter
Stars: ✭ 23 (-70.89%)
Mutual labels:  interpreter, repl
charm
A [ functional stack ] based language.
Stars: ✭ 26 (-67.09%)
Mutual labels:  interpreter, repl
Red
Red is a next-generation programming language strongly inspired by Rebol, but with a broader field of usage thanks to its native-code compiler, from system programming to high-level scripting and cross-platform reactive GUI, while providing modern support for concurrency, all in a zero-install, zero-config, single 1MB file!
Stars: ✭ 4,725 (+5881.01%)
Mutual labels:  interpreter, repl
endbasic
BASIC environment with a REPL, a web interface, a graphical console, and RPi support written in Rust
Stars: ✭ 220 (+178.48%)
Mutual labels:  interpreter, repl
malluscript
A simple,gentle,humble scripting language for mallus, based on malayalam memes.
Stars: ✭ 112 (+41.77%)
Mutual labels:  interpreter, repl
Codi.vim
📔 The interactive scratchpad for hackers.
Stars: ✭ 2,464 (+3018.99%)
Mutual labels:  interpreter, repl
Ok
An open-source interpreter for the K5 programming language.
Stars: ✭ 408 (+416.46%)
Mutual labels:  interpreter, repl
Rascal
The implementation of the Rascal meta-programming language (including interpreter, type checker, parser generator, compiler and JVM based run-time system)
Stars: ✭ 284 (+259.49%)
Mutual labels:  interpreter, repl
fundot
The Fundot programming language.
Stars: ✭ 15 (-81.01%)
Mutual labels:  interpreter, repl
Mico
Mico ("Monkey" in catalan). Monkey language implementation done with C++. https://interpreterbook.com/
Stars: ✭ 19 (-75.95%)
Mutual labels:  interpreter, repl
Go Pry
An interactive REPL for Go that allows you to drop into your code at any point.
Stars: ✭ 2,747 (+3377.22%)
Mutual labels:  interpreter, repl
klisp
A Lisp written in about 200 lines of Ink, featuring an interactive literate programming notebook
Stars: ✭ 28 (-64.56%)
Mutual labels:  interpreter, repl
Mond
A scripting language for .NET Core
Stars: ✭ 237 (+200%)
Mutual labels:  interpreter, repl
huginn
Programming language with no quirks, so simple every child can master it.
Stars: ✭ 41 (-48.1%)
Mutual labels:  interpreter, repl
Janet
A dynamic language and bytecode vm
Stars: ✭ 2,216 (+2705.06%)
Mutual labels:  interpreter, repl
Charly
🐈 The Charly Programming Language | Written by @KCreate
Stars: ✭ 185 (+134.18%)
Mutual labels:  interpreter, repl
retro12
This repo is retired. See http://forthworks.com:8000/
Stars: ✭ 18 (-77.22%)
Mutual labels:  interpreter, repl
Bic
A C interpreter and API explorer.
Stars: ✭ 719 (+810.13%)
Mutual labels:  interpreter, repl

Goto

Goto is an interpreted programming language written in go.

License: MIT Go Report Card Release

1. Overview

Goto is a dynamically typed programming language written to support all the scripting requirements. It currently supports the following:

  • Data Types: integer, boolean, string
  • Data Structures: list
  • Arithimetic Operations: +, -, *, /, %, **
  • Comparisons: ==, !=, <, <=, >, >=
  • Logical Operators: !, &&, ||
  • If-Else-If Statements
  • For loops
  • Control Flow Statements continue, break, return
  • Multiple Assigments
  • Operator Precedence Parsing
  • Grouped Expressions
  • Functions
  • Scopes
  • Comments
  • Error Handling
  • Built in Functions: append, print, len

2. Table of Content

3. Installation

Source Installation

To install goto, run the following command:

go get -u github.com/pandeykartikey/goto

Binary Releases

Alternatively, you could install a binary-release, from the release page.

4. Usage

To execute a goto-script, pass the name to the interpreter:

$ goto sample.to

Scripts can be made executable by adding a suitable shebang line:

#!/usr/bin/env goto

To drop into goto-repl, type goto. To exit from repl, just type exit or Ctrl + D.

5. Syntax

5.1 Definitions

Variables are defined using the var keyword, with each line ending with ;.

var a = 3;

A variable must be declared before its usage. It is not necessary to provide a value while declaring a variable.

var a;

5.1.1 Multiple Assignments

Goto supports multiple assignments and declarations.

var a,b,c = 1,2,3;

The datatypes of all the variables need not be the same.

a,b = 1,true;

5.1.2 Scoping

Goto supports hiding of global variable in block constructs

var a = 4;
if true { var a = 5; print(a);} # prints 5
print(a); # prints 4

5.2 Arithmetic operations

Goto supports all the basic arithmetic operations along with ** operator for power. (Inspired from Python)

square = b**2;
remainder = b%2;

5.3 Lists

List is a data structure that organizes items by linear sequence. It can hold multiple types.

var a = [1, true, "array"];

5.3.1 Indexing

Lists are 0-indexed. Elements can be accessed using []. Similar indexing exists for strings.

var a = [1, true, "array"];
a[1] # returns true
a[2][3] # returns "a"

5.4 Builtin functions

Goto currently supports 3 built-in functions:

  1. len: Returns the length of string or a list.

    len("goto") # returns 4

  2. append: appends a token at the end of an array

    var a = [1, 2]; append(a, 3) # a becomes [1, 2, 3]

  3. print: prints the content of parameters to STDOUT. It can take multiple arguments.

    print(1, 2, "goto") Output: 1 2 goto

5.5 Functions

Goto defines function using func followed by an identifier and a parameter list.

func identity(x) {
    return x;
}

5.5.1 Local Functions

You can define local functions inside a block statement with limited scope.

func addTwo(x) {
  func addOne(x) { # addOne() is limited to addTwo()'s scope
    return x + 1;
  }
  x = addOne(x);
  return addOne(x);
}

5.6 If-else statements

Goto supports if-else-if statements.

var a,b,c = 1,2,3;
if a > b { 
  c = a + b; 
} else if a < c {
  c = 20; 
} else {
  c = 30; 
}
print(c); # returns 20

5.7 For-loop statements

Goto has supports for-loop statements.

for var i = 0; i < 10; i = i + 1 {
   i = i + 2;
   print(i);
}

All the three initialization, condition, and update are optional in for loop.

for ;; {
   i = i + 2;
   print(i);
}

5.8 Control flow statements

There are three control flow statements in goto:

  1. continue: It skips all the following statements in a for loop and moves on to the next iteration.

  2. break: It is used to break a for loop.

  3. return: It is used to terminate a function. It may also be used to return values from functions.

5.9 Comments

Single Line comments are supported by goto.

# This is a comment

6. Contributing

If you spot anything that seems wrong, please do report an issue.

If you feel something is missing in goto, consider creating an issue or submitting a pull request.

7. Acknowledgments

This programming language takes inspiration from the book Write an Interpreter in Go.

8. License

Goto is licensed under MIT License.

9. Contact

If you have any queries regarding the project or just want to say hello, feel free to drop a mail at [email protected].

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].