Skip to content

Commit

Permalink
Merge pull request #268 from Eclalang/issue-#265-remove-node
Browse files Browse the repository at this point in the history
removed the Type node from parser and interpreter
  • Loading branch information
tot0p authored Feb 26, 2024
2 parents 63473b9 + ce040ba commit 3208d06
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 72 deletions.
9 changes: 0 additions & 9 deletions interpreter/Stmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,6 @@ func RunImportStmt(stmt parser.ImportStmt, env *Env) {
env.Import(stmt)
}

// RunTypeStmt executes a parser.TypeStmt.
func RunTypeStmt(tree parser.TypeStmt, env *Env) {
t := RunTree(tree.Expression, env)[0].GetVal()
var typ string
typ = t.GetType()
fmt.Println(typ)
//return eclaType.NewString(RunTree(tree.Expression, env).GetType())
}

// AssignementTypeChecking checks if the type of the variable is the same as the type of the expression.
// If the type of the variable is any, it returns true else it returns false.
func AssignementTypeChecking(tree parser.VariableAssignStmt, type1 string, type2 string, env *Env) bool {
Expand Down
2 changes: 0 additions & 2 deletions interpreter/expr.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ func RunTree(tree parser.Node, env *Env) []*Bus {
return []*Bus{RunUnaryExpr(tree.(parser.UnaryExpr), env)}
case parser.ParenExpr:
return RunTree(tree.(parser.ParenExpr).Expression, env)
case parser.TypeStmt:
RunTypeStmt(tree.(parser.TypeStmt), env)
case parser.VariableDecl:
RunVariableDecl(tree.(parser.VariableDecl), env)
case parser.VariableAssignStmt:
Expand Down
25 changes: 0 additions & 25 deletions parser/NodeTypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,31 +205,6 @@ func (a IndexableAccessExpr) precedence() int {

func (a IndexableAccessExpr) exprNode() {}

type TypeStmt struct {
TypeToken lexer.Token
Lparen lexer.Token
Rparen lexer.Token
Expression Expr
}

func (p TypeStmt) StartPos() int {
return p.TypeToken.Position
}

func (p TypeStmt) EndPos() int {
return p.Rparen.Position
}

func (p TypeStmt) StartLine() int {
return p.TypeToken.Line
}

func (p TypeStmt) EndLine() int {
return p.Rparen.Line
}

func (p TypeStmt) stmtNode() {}

type VariableDecl struct {
VarToken lexer.Token
Name string
Expand Down
36 changes: 0 additions & 36 deletions parser/Nodes-Documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
- [ImportStmt node](#importstmt-node)
- [MurlocStmt node](#murlocstmt-node)
- [ReturnStmt node](#returnstmt-node)
- [TypeStmt node](#typestmt-node)
- [VariableAssignStmt node](#variableassignstmt-node)
- [WhileStmt node](#whilestmt-node)
- [Declaration nodes](#declaration-nodes)
Expand Down Expand Up @@ -786,41 +785,6 @@ for example :

---

#### TypeStmt node

The `TypeStmt` node represents a type statement in the Ecla language.

##### Fields

The `TypeStmt` node is defined as follows :

```go
type TypeStmt struct {
TypeToken lexer.Token
Lparen lexer.Token
Rparen lexer.Token
Expression Expr
}
```

The `TypeToken` field is the token that represents the type statement.
The `Lparen` field is the left parenthesis of the type statement.
The `Rparen` field is the right parenthesis of the type statement.
The `Expression` field is the expression of the type statement.

##### Code Example

a type statement is a statement that contains an expression surrounded by parenthesis.

for example :

```ecla
type(1);
type("hello world");
```

---

#### VariableAssignStmt node

The `VariableAssignStmt` node represents a variable assign statement in the Ecla language.
Expand Down

0 comments on commit 3208d06

Please sign in to comment.