Skip to content

Commit

Permalink
feat: abstract synthax tree contracts definition
Browse files Browse the repository at this point in the history
  • Loading branch information
Houcine EL ADDALI committed Dec 3, 2023
1 parent 554fbb4 commit c85b6fe
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
33 changes: 33 additions & 0 deletions AST/ast_interfaces.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package ast

/*
* Abstract syntax tree is the data structure
* which our parser will return it's is an hierarchical DS
* that represents 'the flow of the tokens' with a top down approach
* It's called abstract because it doesn't include all elements such whitespace break lines ..
*/

/*
* The node type which be contained in the tree
*/
type Node interface{
/*
* The token literal representation in the node
* This will be used only for testing and debugging purposes
*/
TokenLiteral() string
}

/*
* we wil be define for now 2 types of nodes
* Statements nodes: doesn't return any value
* Expression nodes : does return a value
*/
type Statement interface {
Node
statementNode()
}
type Expression interface {
Node
expressionNode()
}
4 changes: 0 additions & 4 deletions lexer/lexer.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package lexer

import (
"fmt"
"unicode/utf8"

"github.com/houcine7/JIPL/token"
Expand Down Expand Up @@ -32,7 +31,6 @@ func (l *Lexer) NextToken() token.Token {
// var tokens []token.Token
var test token.Token
l.ignoreWhiteSpace()
fmt.Println(string(l.char),l.currentPos)

switch l.char{
case '=':
Expand Down Expand Up @@ -104,8 +102,6 @@ func (l *Lexer) NextToken() token.Token {
}
}

fmt.Print(test)

l.readChar() // move to next char
return test
}
Expand Down

0 comments on commit c85b6fe

Please sign in to comment.