fleshed out GetVar, added Token stack collection, started printing module

This commit is contained in:
Aidan Hahn 2019-11-28 08:57:12 -08:00
parent 516fda54b3
commit 84013cb4a0
No known key found for this signature in database
GPG key ID: 327711E983899316
6 changed files with 89 additions and 2 deletions

22
pkg/shsh/stack.go Normal file
View file

@ -0,0 +1,22 @@
package shsh
type TokenStack struct {
buffer []*Token
int capacity
}
func (s *Stack) Push(v *Token) {
s.capacity++
*s.buffer = append(*s.buffer, v)
}
func (s *Stack) Pop() *Token {
if s.capacity <= 0 {
return nil
}
s.capacity--
res := *s.buffer[len(*s.buffer) - 1]
*s = *s.buffer[ :len(*s) - 1]
return ret
}