Answer architecture round 1: calls carry no operands in the grammar, ParseCalc returns its operands, one empty-segment check, sorted token kinds, and file items 110 and 111
This commit is contained in:
@@ -6,8 +6,6 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// IsTemplate reports whether arg is an inline template rather than a path, by its shape;
|
||||
// the root's IsTemplate documents the rule.
|
||||
func IsTemplate(arg string) (bool, error) {
|
||||
if strings.ContainsRune(arg, '{') || (isJSONStart(strings.TrimSpace(arg)) && json.Valid([]byte(arg))) {
|
||||
if path, lone := loneReference(arg); lone {
|
||||
@@ -56,7 +54,7 @@ func loneReference(arg string) (string, bool) {
|
||||
if !isString {
|
||||
return "", false
|
||||
}
|
||||
toks, err := ParseFormat(format, nil)
|
||||
toks, err := ParseFormat(format)
|
||||
if err != nil {
|
||||
return "", false
|
||||
}
|
||||
@@ -73,8 +71,8 @@ func loneReference(arg string) (string, bool) {
|
||||
|
||||
// loneRef is the reference a format of one reference token and nothing else reads.
|
||||
func loneRef(toks []Token) (string, bool) {
|
||||
if len(toks) != 1 || toks[0].Kind != NameRead || len(toks[0].Names) != 1 || !IsRef(toks[0].Names[0]) {
|
||||
if len(toks) != 1 || toks[0].Kind != NameRead || len(toks[0].Arms) != 1 || !IsRef(toks[0].Arms[0]) {
|
||||
return "", false
|
||||
}
|
||||
return toks[0].Names[0], true
|
||||
return toks[0].Arms[0], true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user