Update name change.

This commit is contained in:
Tijani Lawal 2024-08-28 19:31:35 -05:00
parent d9d8a27568
commit 6a96a3dd25
17 changed files with 68 additions and 25 deletions

43
README.md Normal file
View File

@ -0,0 +1,43 @@
## Monna Programming Language
This project is a result of learning the innards of compilers. Among other compiler books that I learned from, this was the most influential, especially in making this project: [Writing an Interpreter In Go](https://interpreterbook.com/).
![Demo of Monna working](/doc/demo.png)
### Using
To use the Monna interpreter, simply run `go run main.go` in the project directory.To get an executable, run `go build` in the project directory.
### Features
#### Variables:
let x = 5;
#### Return Statements:
return 5;
return false;
#### Expressions:
if (x < y) { x }
if (x > y) { y } else { x }
#### Functions:
fn(x, y) { x + y; }
#### String Literals:
"Hello World"
#### Built-in Functions:
- **len()**: Returns the number of characters in a string.
```
len("Dexter's Laboratory");
19
```
- **puts()**: Prints the given arguments to STDOUT. It return a null. It only cares about printing not returning a value.
```
puts("Sugar, spice, and everything nice!");
Sugar, spice, and everything nice!
```
#### Error Handling:
The Monna programming language also responds accordingly to errors:
![Error Handling](/doc/error_handling.png)

View File

@ -2,7 +2,7 @@ package ast
import (
"bytes"
"monkey/token"
"monna/token"
"strings"
)

View File

@ -1,7 +1,7 @@
package ast
import (
"monkey/token"
"monna/token"
"testing"
)

BIN
doc/demo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
doc/error_handling.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 288 KiB

View File

@ -2,7 +2,7 @@ package evaluator
import(
"fmt"
"monkey/object"
"monna/object"
)
var builtins = map[string]*object.Builtin{

View File

@ -2,8 +2,8 @@ package evaluator
import (
"fmt"
"monkey/ast"
"monkey/object"
"monna/ast"
"monna/object"
)
var (

View File

@ -1,9 +1,9 @@
package evaluator
import (
"monkey/lexer"
"monkey/object"
"monkey/parser"
"monna/lexer"
"monna/object"
"monna/parser"
"testing"
)

2
go.mod
View File

@ -1,3 +1,3 @@
module monkey
module monna
go 1.18

View File

@ -1,6 +1,6 @@
package lexer
import "monkey/token"
import "monna/token"
type Lexer struct {
input string

View File

@ -3,7 +3,7 @@ package lexer
import (
"testing"
"monkey/token"
"monna/token"
)
func TestNextToken(t *testing.T) {

View File

@ -11,10 +11,10 @@ import (
"fmt"
"os"
"monkey/repl"
"monna/repl"
)
func main() {
fmt.Printf("Welcome to the Monk programming language!\n")
fmt.Printf("Hello human, type some commands: \n")
repl.Start(os.Stdin, os.Stdout)
}

View File

@ -20,7 +20,7 @@ func NewEnvironment() *Environment {
/*
Enclosing Environments
Here is a problem case, lets say in monkey I would want to type this:
Here is a problem case, lets say in monna I would want to type this:
```
let i = 5;
@ -32,7 +32,7 @@ func NewEnvironment() *Environment {
puts(i);
```
The ideal result of the above code in the monkey programming language is for 10 and 5 to be the outputs respectively.
The ideal result of the above code in the monna programming language is for 10 and 5 to be the outputs respectively.
In a situation where enclosed environment does not exists, both outputs will be 10 because the current value of i
would be overwritten. The ideal situation would be to preserve the previous binding to 'i' while also making a a new
one.

View File

@ -3,7 +3,7 @@ package object
import (
"bytes"
"fmt"
"monkey/ast"
"monna/ast"
"strings"
)

View File

@ -2,9 +2,9 @@ package parser
import (
"fmt"
"monkey/ast"
"monkey/lexer"
"monkey/token"
"monna/ast"
"monna/lexer"
"monna/token"
"strconv"
)

View File

@ -3,8 +3,8 @@ package parser
import (
"fmt"
"monkey/ast"
"monkey/lexer"
"monna/ast"
"monna/lexer"
"testing"
)

View File

@ -4,10 +4,10 @@ import (
"bufio"
"fmt"
"io"
"monkey/evaluator"
"monkey/lexer"
"monkey/object"
"monkey/parser"
"monna/evaluator"
"monna/lexer"
"monna/object"
"monna/parser"
)
const MONKEY_FACE = ` __,__