Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
grngxd committed May 30, 2022
1 parent 7d551c1 commit 202896b
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 0 deletions.
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module aoki

go 1.18
2 changes: 2 additions & 0 deletions main.aoki
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// this is a comment
print 9
21 changes: 21 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package main

import (
run "aoki/run"
"fmt"
"os"
)

func main() {
args := os.Args[1:]

if len(args) != 0 {
if args[0] == "run" {
run.Run(args[1])
} else {
fmt.Println("You are trying to run a command")
}
} else {
fmt.Println("Aoki")
}
}
38 changes: 38 additions & 0 deletions run/run.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package aoki

import (
"bufio"
"fmt"
"os"
"strings"
)

func Run(filePath string) {
readFile, err := os.Open(filePath)
if err != nil {
fmt.Println(err)
}

fileScanner := bufio.NewScanner(readFile)
fileScanner.Split(bufio.ScanLines)
var fileLines []string

for fileScanner.Scan() {
fileLines = append(fileLines, fileScanner.Text())
}

readFile.Close()

for _, line := range fileLines {
if strings.HasPrefix(line, "//") {
continue
} else if strings.HasPrefix(line, "print") {
args := (strings.Split(line, " "))[1]
if strings.HasPrefix(args, "\"") && strings.HasSuffix(args, "\"") {
fmt.Println(args[1 : len(args)-1])
} else {
fmt.Println(args)
}
}
}
}

0 comments on commit 202896b

Please sign in to comment.