Skip to content

Commit

Permalink
docs: add more demo (#21)
Browse files Browse the repository at this point in the history
## What does this PR do?

+ add more demo
+ upgrade go version from 1.21 to 1.22 in ci workflow
  • Loading branch information
Aden-Q authored May 15, 2024
1 parent bc7bcc7 commit fc04133
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 7 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.21'
go-version: '1.22'

- name: Install dependencies
run: go get ./...
Expand Down
41 changes: 35 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Monkey is an interpreted language written in Go. *This project is still under de

## Usage

### Local Build and Run
### Local build and run

Open your shell, then REPL is ready for you:

Expand Down Expand Up @@ -54,7 +54,7 @@ Hello xxx! This is the Monkey programming language!
>>>
```

### Binary Installation
### Binary installation

Assuming you have `$GOPATH` appended to your `$PATH` env var:

Expand All @@ -77,6 +77,17 @@ Hello xxx! This is the Monkey programming language!

## Demo

For more examples and language details. Please check the blog post [here]().

### Built-in functions

```bash
>>> print("Hello, world!");
Hello, world!
>>> len("Hello, world!");
13
```

### Functions

Anonymous function and function binding:
Expand All @@ -89,18 +100,35 @@ Anonymous function and function binding:
10
```

### Conditionals
### Control structures

Simple if condition with an else branch:
#### If

```bash
>>> if (10 > 5) { 5; } else { 10; };
5
```
### Arrays
```bash
>>> let arr = [1, 2, 3, 4, 5];
>>> arr[0];
1
```
### Hashes
```bash
>>> let person = {"name": "alice", "age": 21};
>>> person["name"];
alice
```
## Conventions and Features
+ Programs can run in REPL or as scripts
+ Primitive data types: `int`, `boolean`, `string`
+ Identifiers consist of alphabet letters or underscore
+ Statements are explicitly end by seminlon `;`
+ Comments start with double slash `//`
Expand All @@ -120,8 +148,8 @@ Simple if condition with an else branch:
+ Lexer
+ Abstract Syntax Tree (AST)
+ Pratt parser based on context-free grammars and the Backus-Naur-Form
+ Tree-walking interpreter (evaluator), future: bytecode, VM, and JIT compilation
+ An object system
+ Tree-walking interpreter/evaluator
+ Object system
## TODOs
Expand Down Expand Up @@ -183,6 +211,7 @@ Simple if condition with an else branch:
+ [ ] feat: mutable array implementation for efficient push/pop
+ [ ] feat: map-reduce as an example
+ [ ] feat: iterator, range operator
+ [ ] feat: bytecode, VM, and JIT compilation
## References
Expand Down

0 comments on commit fc04133

Please sign in to comment.