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:
@@ -2,6 +2,7 @@ package grammar
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"slices"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -160,3 +161,12 @@ func JoinSegments(segs []string) string {
|
||||
}
|
||||
return b.String()
|
||||
}
|
||||
|
||||
// CheckSegments refuses an unfinished path: "a." and "a...b" each have a segment naming
|
||||
// nothing.
|
||||
func CheckSegments(segs []string) error {
|
||||
if slices.Contains(segs, "") {
|
||||
return fmt.Errorf("path has an empty segment")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user