Skip to content

Commit 96e1b62

Browse files
committed
chore: renamed the errorsModule
1 parent 90c99b9 commit 96e1b62

8 files changed

Lines changed: 35 additions & 24 deletions

File tree

Interpreter/interpreter.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import (
44
"fmt"
55
"strconv"
66

7-
"github.com/shubhdevelop/Lox/LoxErrors"
87
"github.com/shubhdevelop/Lox/Token"
98
"github.com/shubhdevelop/Lox/ast"
109
"github.com/shubhdevelop/Lox/environment"
10+
"github.com/shubhdevelop/Lox/yaplErrors"
1111
)
1212

1313
type Interpreter struct {
@@ -50,7 +50,7 @@ func (i *Interpreter) VisitBinaryExpr(expr ast.Binary) interface{} {
5050
case token.MINUS:
5151
return left.(float64) - right.(float64)
5252
case token.PLUS:
53-
runtimeError := loxErrors.RuntimeError{
53+
runtimeError := yaplErrors.RuntimeError{
5454
Token: expr.Operator,
5555
Message: "Operands must be two numbers or two strings.",
5656
}
@@ -182,7 +182,7 @@ func stringify(obj interface{}) string {
182182
}
183183

184184
func (i Interpreter) checkNumberOperand(operator token.Token, left, right interface{}) {
185-
runtimeError := loxErrors.RuntimeError{
185+
runtimeError := yaplErrors.RuntimeError{
186186
Token: operator,
187187
Message: "Operands must be numbers.",
188188
}

Scanner/scanner.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package scanner
22

33
import (
44
"errors"
5-
"github.com/shubhdevelop/Lox/LoxErrors"
65
"github.com/shubhdevelop/Lox/Token"
6+
"github.com/shubhdevelop/Lox/yaplErrors"
77
"strconv"
88
)
99

@@ -110,7 +110,7 @@ func (s *Scanner) string() {
110110
s.advance()
111111
}
112112
if s.isAtEnd() {
113-
loxErrors.ThrowNewError(s.line, "Unterminated string.")
113+
yaplErrors.ThrowNewError(s.line, "Unterminated string.")
114114
return
115115
}
116116
s.advance()
@@ -138,7 +138,7 @@ func (s *Scanner) number() {
138138
value := s.Source[s.start:s.current]
139139
valueInFloat, err := strconv.ParseFloat(value, 64)
140140
if err != nil {
141-
loxErrors.ThrowNewError(s.line, "Unexpected Numerical Value")
141+
yaplErrors.ThrowNewError(s.line, "Unexpected Numerical Value")
142142
}
143143
s.addToken(token.NUMBER, valueInFloat)
144144
}
@@ -226,7 +226,7 @@ func (s *Scanner) scanToken() {
226226
} else if s.isAlpha(c) {
227227
s.identifier()
228228
} else {
229-
loxErrors.ThrowNewError(s.line, "Unexpected Character Encountered")
229+
yaplErrors.ThrowNewError(s.line, "Unexpected Character Encountered")
230230
}
231231
}
232232
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
package loxErrors
1+
package yaplErrors
22

33
import (
44
"fmt"
55
"os"
66

7-
"github.com/shubhdevelop/Lox/state"
87
"github.com/shubhdevelop/Lox/Token"
8+
"github.com/shubhdevelop/Lox/state"
99
)
1010

1111
type RuntimeError struct {

environment/environmnent.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package environment
22

33
import (
44
"fmt"
5-
loxErrors "github.com/shubhdevelop/Lox/LoxErrors"
65
"github.com/shubhdevelop/Lox/Token"
6+
"github.com/shubhdevelop/Lox/yaplErrors"
77
)
88

99
type Environment struct {
@@ -40,7 +40,7 @@ func (e *Environment) Get(name token.Token) (interface{}, error) {
4040
return e.Enclosing.Get(name)
4141
}
4242

43-
error := loxErrors.RuntimeError{
43+
error := yaplErrors.RuntimeError{
4444
Token: name,
4545
Message: fmt.Sprintf("Undefined variable '%s'.", name.Lexeme),
4646
}
@@ -59,7 +59,7 @@ func (e *Environment) Assign(name token.Token, value interface{}) {
5959
return
6060
}
6161

62-
error := loxErrors.RuntimeError{
62+
error := yaplErrors.RuntimeError{
6363
Token: name,
6464
Message: "Undefined variable '" + name.Lexeme + "'.",
6565
}
File renamed without changes.

main.lox

Lines changed: 0 additions & 8 deletions
This file was deleted.

main.yapl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
var a = "global a";
2+
var b = "global b";
3+
var c = "global c";
4+
{
5+
var a = "outer a";
6+
var b = "outer b";
7+
{
8+
var a = "inner a";
9+
print a;
10+
print b;
11+
print c;
12+
}
13+
print a;
14+
print b;
15+
print c;
16+
}
17+
print a;
18+
print b;
19+
print c;

parser/parser.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ package parser
33
import (
44
"errors"
55

6-
"github.com/shubhdevelop/Lox/LoxErrors"
76
"github.com/shubhdevelop/Lox/Token"
87
"github.com/shubhdevelop/Lox/ast"
8+
"github.com/shubhdevelop/Lox/yaplErrors"
99
)
1010

1111
type Parser struct {
@@ -14,7 +14,7 @@ type Parser struct {
1414
}
1515

1616
func (p *Parser) error(token token.Token, message string) error {
17-
loxErrors.Error(token, message)
17+
yaplErrors.Error(token, message)
1818
return errors.New("Error while parsing")
1919
}
2020

@@ -55,7 +55,7 @@ func (p *Parser) assignment() ast.Expr {
5555
Value: value,
5656
}
5757
}
58-
loxErrors.Error(equals, "Invalid assignment target.")
58+
yaplErrors.Error(equals, "Invalid assignment target.")
5959
}
6060
return expr
6161
}
@@ -209,7 +209,7 @@ func (p *Parser) Parse() []ast.Stmt {
209209
func (p *Parser) declaration() ast.Stmt {
210210
defer func() {
211211
if r := recover(); r != nil {
212-
if _, ok := r.(loxErrors.RuntimeError); ok {
212+
if _, ok := r.(yaplErrors.RuntimeError); ok {
213213
p.synchronize()
214214
} else {
215215
panic(r) // rethrow if it's not a ParseError

0 commit comments

Comments
 (0)