First pass at displaying Menu files

This commit is contained in:
2018-12-30 23:23:08 +00:00
parent 6d3a13fcfb
commit b21767fe97
7 changed files with 559 additions and 2 deletions

View File

@@ -7,6 +7,7 @@ import (
"io"
"os"
"strconv"
"strings"
)
var hashComment = []byte("#")
@@ -60,6 +61,22 @@ func (s *Scanner) ConsumeString() (string, error) {
return "", err
}
// It's common for properties to be specified as "foo : bar". Parse them out.
func ConsumeProperty(s string) (string, string) {
if !IsProperty(s) {
return "", ""
}
parts := strings.SplitN(s, ":", 2)
return strings.TrimSpace(parts[0]), strings.TrimSpace(parts[1])
}
// Peek ahead in the input stream to see if the next line might be a property
// (contain a colon character).
func IsProperty(s string) bool {
return strings.Contains(s, ":")
}
func (s *Scanner) ConsumeInt() (int, error) {
str, err := s.ConsumeString()
if err != nil {