ast package full godoc

This commit is contained in:
Aidan 2020-07-18 14:40:35 -07:00
parent 956044cfae
commit fec3550702
No known key found for this signature in database
GPG key ID: 327711E983899316
7 changed files with 68 additions and 26 deletions

View file

@ -17,16 +17,23 @@
package ast
/* primitive stack type for tokens
* useful for iterative algorithms on tokens
*/
type TokenStack struct {
buffer []*Token
capacity int
}
/* push token onto stack
*/
func (s *TokenStack) Push(v *Token) {
s.capacity++
s.buffer = append(s.buffer, v)
}
/* pop token off stack
*/
func (s *TokenStack) Pop() *Token {
if s.capacity <= 0 {
return nil