package cmpd
import (
)
func ( *parse.Compound) (*parse.Primary, bool) {
if len(.Indexings) == 1 && len(.Indexings[0].Indicies) == 0 {
return .Indexings[0].Head, true
}
return nil, false
}
func ( *parse.Compound) (string, bool) {
if , := Primary(); {
switch .Type {
case parse.Bareword, parse.SingleQuoted, parse.DoubleQuoted:
return .Value, true
}
}
return "", false
}
func ( *parse.Compound) (*parse.Primary, bool) {
if , := Primary(); {
if .Type == parse.Lambda {
return , true
}
}
return nil, false
}
func ( *parse.Compound, string) (string, error) {
, := StringLiteral()
if ! {
return "", fmt.Errorf("%s must be string literal, found %s", , Shape())
}
return , nil
}
func ( *parse.Compound) string {
if len(.Indexings) == 0 {
return "empty expression"
}
if len(.Indexings) > 1 {
return "compound expression"
}
:= .Indexings[0]
if len(.Indicies) > 0 {
return "indexing expression"
}
:= .Head
return "primary expression of type " + .Type.String()
}