M .vscode/launch.json => .vscode/launch.json +3 -1
@@ 19,7 19,9 @@
"program": "cmd/rhumb/main.go",
"args": [
"line",
- "foo .= 10; bar .= 3; foo ** bar // 6"
+ "foo .= 10",
+ "bar .= 3",
+ "foo ** bar // 6"
]
}
M cmd/rhumb/main.go => cmd/rhumb/main.go +2 -2
@@ 22,8 22,8 @@ func main() {
},
{
Name: "line",
- Description: "evaluates line and any connected files",
- ExecFunc: cli.ParseLine,
+ Description: "evaluates lines and any connected files",
+ ExecFunc: cli.ParseLines,
},
{
Name: "repl",
M internal/cli/cli.go => internal/cli/cli.go +4 -3
@@ 7,6 7,7 @@ import (
"fmt"
"io"
"os"
+ "strings"
"git.sr.ht/~madcapjake/grhumb/internal/generator"
"git.sr.ht/~madcapjake/grhumb/internal/parser"
@@ 48,9 49,9 @@ func ParseFile(ctx context.Context, args []string) error {
return nil
}
-func ParseLine(ctx context.Context, args []string) error {
+func ParseLines(ctx context.Context, args []string) error {
fmt.Println("Parsing line...")
- input := antlr.NewInputStream(args[0])
+ input := antlr.NewInputStream(strings.Join(args, "\n"))
parse(ctx.Value(VisitorCK).(*generator.RhumbVisitor), input)
return nil
}
@@ 69,7 70,7 @@ func ReadEvalPrintLoop(ctx context.Context, args []string) error {
fmt.Fprintf(os.Stderr, "ERROR: %s\n", err)
os.Exit(1)
}
- if err = ParseLine(ctx, []string{text}); err != nil {
+ if err = ParseLines(ctx, []string{text}); err != nil {
fmt.Fprintf(os.Stderr, "ERROR: %s\n", err)
}
}