Reorganized file structure
This commit is contained in:
parent
c2401bf826
commit
7b18056006
@ -1,63 +1,6 @@
|
||||
package ast
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.akyoto.dev/cli/q/src/build/expression"
|
||||
"git.akyoto.dev/cli/q/src/build/token"
|
||||
)
|
||||
import "fmt"
|
||||
|
||||
type Node fmt.Stringer
|
||||
type AST []Node
|
||||
|
||||
type Assign struct {
|
||||
Value *expression.Expression
|
||||
Name token.Token
|
||||
Operator token.Token
|
||||
}
|
||||
|
||||
func (node *Assign) String() string {
|
||||
return fmt.Sprintf("(= %s %s)", node.Name.Text(), node.Value)
|
||||
}
|
||||
|
||||
type Call struct {
|
||||
Expression *expression.Expression
|
||||
}
|
||||
|
||||
func (node *Call) String() string {
|
||||
return node.Expression.String()
|
||||
}
|
||||
|
||||
type Define struct {
|
||||
Value *expression.Expression
|
||||
Name token.Token
|
||||
}
|
||||
|
||||
func (node *Define) String() string {
|
||||
return fmt.Sprintf("(= %s %s)", node.Name.Text(), node.Value)
|
||||
}
|
||||
|
||||
type If struct {
|
||||
Condition *expression.Expression
|
||||
Body AST
|
||||
}
|
||||
|
||||
func (node *If) String() string {
|
||||
return fmt.Sprintf("(if %s %s)", node.Condition, node.Body)
|
||||
}
|
||||
|
||||
type Loop struct {
|
||||
Body AST
|
||||
}
|
||||
|
||||
func (node *Loop) String() string {
|
||||
return fmt.Sprintf("(loop %s)", node.Body)
|
||||
}
|
||||
|
||||
type Return struct {
|
||||
Value *expression.Expression
|
||||
}
|
||||
|
||||
func (node *Return) String() string {
|
||||
return fmt.Sprintf("(return %s)", node.Value)
|
||||
}
|
||||
|
19
src/build/ast/Assign.go
Normal file
19
src/build/ast/Assign.go
Normal file
@ -0,0 +1,19 @@
|
||||
package ast
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.akyoto.dev/cli/q/src/build/expression"
|
||||
"git.akyoto.dev/cli/q/src/build/token"
|
||||
)
|
||||
|
||||
// Assign represents an assignment to an existing variable or memory location.
|
||||
type Assign struct {
|
||||
Value *expression.Expression
|
||||
Name token.Token
|
||||
Operator token.Token
|
||||
}
|
||||
|
||||
func (node *Assign) String() string {
|
||||
return fmt.Sprintf("(= %s %s)", node.Name.Text(), node.Value)
|
||||
}
|
12
src/build/ast/Call.go
Normal file
12
src/build/ast/Call.go
Normal file
@ -0,0 +1,12 @@
|
||||
package ast
|
||||
|
||||
import "git.akyoto.dev/cli/q/src/build/expression"
|
||||
|
||||
// Call represents a function call.
|
||||
type Call struct {
|
||||
Expression *expression.Expression
|
||||
}
|
||||
|
||||
func (node *Call) String() string {
|
||||
return node.Expression.String()
|
||||
}
|
18
src/build/ast/Define.go
Normal file
18
src/build/ast/Define.go
Normal file
@ -0,0 +1,18 @@
|
||||
package ast
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.akyoto.dev/cli/q/src/build/expression"
|
||||
"git.akyoto.dev/cli/q/src/build/token"
|
||||
)
|
||||
|
||||
// Define represents a variable definition.
|
||||
type Define struct {
|
||||
Value *expression.Expression
|
||||
Name token.Token
|
||||
}
|
||||
|
||||
func (node *Define) String() string {
|
||||
return fmt.Sprintf("(= %s %s)", node.Name.Text(), node.Value)
|
||||
}
|
17
src/build/ast/If.go
Normal file
17
src/build/ast/If.go
Normal file
@ -0,0 +1,17 @@
|
||||
package ast
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.akyoto.dev/cli/q/src/build/expression"
|
||||
)
|
||||
|
||||
// If represents an if statement.
|
||||
type If struct {
|
||||
Condition *expression.Expression
|
||||
Body AST
|
||||
}
|
||||
|
||||
func (node *If) String() string {
|
||||
return fmt.Sprintf("(if %s %s)", node.Condition, node.Body)
|
||||
}
|
12
src/build/ast/Loop.go
Normal file
12
src/build/ast/Loop.go
Normal file
@ -0,0 +1,12 @@
|
||||
package ast
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Loop represents a block of repeatable statements.
|
||||
type Loop struct {
|
||||
Body AST
|
||||
}
|
||||
|
||||
func (node *Loop) String() string {
|
||||
return fmt.Sprintf("(loop %s)", node.Body)
|
||||
}
|
16
src/build/ast/Return.go
Normal file
16
src/build/ast/Return.go
Normal file
@ -0,0 +1,16 @@
|
||||
package ast
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.akyoto.dev/cli/q/src/build/expression"
|
||||
)
|
||||
|
||||
// Return represents a return statement.
|
||||
type Return struct {
|
||||
Value *expression.Expression
|
||||
}
|
||||
|
||||
func (node *Return) String() string {
|
||||
return fmt.Sprintf("(return %s)", node.Value)
|
||||
}
|
Loading…
Reference in New Issue
Block a user