-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement a simple Pratt Parser (#1)
* init return statements * Update ast.go * init ast * add integer ast * add prefix operations * add infix operations * remove logs * Add boolean support * add grouped operations * Create ci.yaml * Add if else support * Add function call support * Add function call support * update tests * Add errors to repl
- Loading branch information
Showing
9 changed files
with
1,223 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Go | ||
|
||
on: | ||
push: | ||
branches: ["main"] | ||
pull_request: | ||
|
||
workflow_dispatch: | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.22 | ||
|
||
- name: Set up gotestfmt | ||
uses: gotesttools/gotestfmt-action@v2 | ||
|
||
- name: Run tests | ||
run: | | ||
set -euo pipefail | ||
go test -json -v ./... 2>&1 | tee /tmp/gotest.log | gotestfmt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
bin | ||
bin | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package ast | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/sevenreup/chewa/src/token" | ||
) | ||
|
||
func TestString(t *testing.T) { | ||
program := &Program{ | ||
Statements: []Statement{ | ||
&AssigmentStatement{ | ||
Token: token.Token{Type: token.INTEGER, Literal: "nambala"}, | ||
Name: &Identifier{ | ||
Token: token.Token{Type: token.IDENT, Literal: "myVar"}, | ||
Value: "myVar", | ||
}, | ||
Value: &Identifier{ | ||
Token: token.Token{Type: token.IDENT, Literal: "anotherVar"}, | ||
Value: "anotherVar", | ||
}, | ||
}, | ||
}, | ||
} | ||
if program.String() != "nambala myVar = anotherVar;" { | ||
t.Errorf("program.String() wrong. got=%q", program.String()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.