
This commit includes updates that affects the build, testing, and deployment of Tile38. - The root level build.sh has been broken up into multiple scripts and placed in the "scripts" directory. - The vendor directory has been updated to follow the Go modules rules, thus `make` should work on isolated environments. Also some vendored packages may have been updated to a later version, if needed. - The Makefile has been updated to allow for making single binaries such as `make tile38-server`. There is some scaffolding during the build process, so from now on all binaries should be made using make. For example, to run a development version of the tile38-cli binary, do this: make tile38-cli && ./tile38-cli not this: go run cmd/tile38-cli/main.go - Travis.CI docker push script has been updated to address a change to Docker's JSON repo meta output, which in turn fixes a bug where new Tile38 versions were not being properly pushed to Docker
61 lines
1.2 KiB
Go
61 lines
1.2 KiB
Go
package ini
|
|
|
|
import (
|
|
"bytes"
|
|
"fmt"
|
|
)
|
|
|
|
// ParseStack is a stack that contains a container, the stack portion,
|
|
// and the list which is the list of ASTs that have been successfully
|
|
// parsed.
|
|
type ParseStack struct {
|
|
top int
|
|
container []AST
|
|
list []AST
|
|
index int
|
|
}
|
|
|
|
func newParseStack(sizeContainer, sizeList int) ParseStack {
|
|
return ParseStack{
|
|
container: make([]AST, sizeContainer),
|
|
list: make([]AST, sizeList),
|
|
}
|
|
}
|
|
|
|
// Pop will return and truncate the last container element.
|
|
func (s *ParseStack) Pop() AST {
|
|
s.top--
|
|
return s.container[s.top]
|
|
}
|
|
|
|
// Push will add the new AST to the container
|
|
func (s *ParseStack) Push(ast AST) {
|
|
s.container[s.top] = ast
|
|
s.top++
|
|
}
|
|
|
|
// MarkComplete will append the AST to the list of completed statements
|
|
func (s *ParseStack) MarkComplete(ast AST) {
|
|
s.list[s.index] = ast
|
|
s.index++
|
|
}
|
|
|
|
// List will return the completed statements
|
|
func (s ParseStack) List() []AST {
|
|
return s.list[:s.index]
|
|
}
|
|
|
|
// Len will return the length of the container
|
|
func (s *ParseStack) Len() int {
|
|
return s.top
|
|
}
|
|
|
|
func (s ParseStack) String() string {
|
|
buf := bytes.Buffer{}
|
|
for i, node := range s.list {
|
|
buf.WriteString(fmt.Sprintf("%d: %v\n", i+1, node))
|
|
}
|
|
|
|
return buf.String()
|
|
}
|