-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add a simple REPL to print lexing results (#2)
## What does this PR do? add a simple REPL to print lexing results
- Loading branch information
Zecheng
authored
Apr 28, 2024
1 parent
1410f00
commit 92b760a
Showing
10 changed files
with
122 additions
and
20 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,7 @@ | ||
--- | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "monthly" |
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,18 @@ | ||
name: Check for conventional commit compliance | ||
|
||
on: | ||
pull_request: | ||
types: [opened, ready_for_review, edited] | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
check-cc: | ||
name: Check for conventional commit compliance | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: agenthunt/[email protected] | ||
with: | ||
pr-title-regex: '^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\((\w|-)+\))?(!)?:.*' |
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
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
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,46 @@ | ||
package repl | ||
|
||
import ( | ||
"bufio" | ||
"fmt" | ||
"io" | ||
|
||
"github.com/Aden-Q/monkey/internal/lexer" | ||
"github.com/Aden-Q/monkey/internal/token" | ||
) | ||
|
||
const PROMPT = ">>> " | ||
|
||
type REPL interface { | ||
Start(in io.ReadCloser, out io.WriteCloser) | ||
} | ||
|
||
type Config struct { | ||
} | ||
|
||
type repl struct { | ||
} | ||
|
||
func New(config Config) REPL { | ||
return &repl{} | ||
} | ||
|
||
func (r *repl) Start(in io.ReadCloser, out io.WriteCloser) { | ||
scanner := bufio.NewScanner(in) | ||
|
||
for { | ||
fmt.Print(PROMPT) | ||
|
||
scanned := scanner.Scan() | ||
if !scanned { | ||
return | ||
} | ||
|
||
line := scanner.Text() | ||
l := lexer.New(line) | ||
|
||
for tok, ok := l.NextToken(); ok && tok.Type != token.EOF; tok, ok = l.NextToken() { | ||
fmt.Printf("%+v\n", tok) | ||
} | ||
} | ||
} |
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,13 @@ | ||
package repl_test | ||
|
||
import ( | ||
"testing" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
func TestRepl(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "Repl Suite") | ||
} |
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,10 @@ | ||
package repl_test | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo/v2" | ||
_ "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("Repl", func() { | ||
|
||
}) |
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