blob: 5f60315fe4cf63da9dcb6f92e553948cd40a6365 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
package lexpr
type TokenStack []Token
func (s *TokenStack) Push(item Token) {
*s = append(*s, item)
}
func (s *TokenStack) Pop() (item Token) {
if len(*s) == 0 {
return
}
*s, item = (*s)[:len(*s)-1], (*s)[len(*s)-1]
return item
}
func (s *TokenStack) Head() (item Token) {
if len(*s) == 0 {
return
}
return (*s)[len(*s)-1]
}
|