diff --git a/parser.go b/parser.go index e4e5634..19d46e8 100644 --- a/parser.go +++ b/parser.go @@ -325,6 +325,14 @@ func couldBeACollection(t *term) bool { return sym == SymList || sym == SymString || sym == SymDict || sym == SymExpression || sym == SymVariable } +// func areSymbolsOutOfCtx(tk *Token, ctxTerm *term, syms ...Symbol) bool { +// var areOut = false +// if ctxTerm != nil { +// areOut = tk.IsOneOf(syms) +// } +// return areOut +// } + func (self *parser) parseGeneral(scanner *scanner, allowForest bool, allowVarRef bool, termSymbols ...Symbol) (tree *ast, err error) { var selectorTerm *term = nil var currentTerm *term = nil @@ -332,7 +340,7 @@ func (self *parser) parseGeneral(scanner *scanner, allowForest bool, allowVarRef tree = NewAst() firstToken := true // lastSym := SymUnknown - for tk = scanner.Next(); err == nil && tk != nil && !tk.IsTerm(termSymbols); tk = scanner.Next() { + for tk = scanner.Next(); err == nil && tk != nil && !tk.IsTerm(termSymbols); /*&& !areSymbolsOutOfCtx(tk, selectorTerm, SymColon, SymDoubleColon)*/ tk = scanner.Next() { if tk.Sym == SymComment { continue } @@ -438,6 +446,10 @@ func (self *parser) parseGeneral(scanner *scanner, allowForest bool, allowVarRef } else { currentTerm, err = tree.addToken2(tk) } + if tk.IsSymbol(SymColon) { + // Colon outside a selector term acts like a separator + firstToken = true + } default: currentTerm, err = tree.addToken2(tk) }