Skip to content

Commit

Permalink
Creates initial abstract syntax tree data structure (#11)
Browse files Browse the repository at this point in the history
* Creates intial abstract syntax tree datastructure

* Updates pull request template
  • Loading branch information
abasnfarah authored Jan 31, 2024
1 parent 9d662cb commit d32f6b5
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions go/ast/ast.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package ast

type Node interface {
tokenLiteral() string
}

type Statement interface {
Node
statementNode()
}

type Expression interface {
Node
expressionNode()
}

type Program struct {
Statements []Statement
}

func (p *Program) tokenLiteral() string {
if len(p.Statements) > 0 {
return p.Statements[0].tokenLiteral()
}
return ""
}

0 comments on commit d32f6b5

Please sign in to comment.