ast package full godoc
This commit is contained in:
parent
956044cfae
commit
fec3550702
7 changed files with 68 additions and 26 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue