/** We treat the property value section as a list value, which is separated by ',' or ' ' */ func (parser *Parser) ParsePropertyValue(parentRuleSet *ast.RuleSet, property *ast.Property) *ast.List { debug("ParsePropertyValue") // var tok = parser.peek() var list = ast.NewSpaceSepList() var tok = parser.peek() for tok.Type != ast.T_SEMICOLON && tok.Type != ast.T_BRACE_CLOSE { var sublist = parser.ParseList() if sublist != nil { list.Append(sublist) debug("ParsePropertyValue list: %+v", list) } else { break } tok = parser.peek() } return list }
func (parser *Parser) ParseSpaceSepList() ast.Expr { debug("ParseSpaceSepList at %d", parser.Pos) var list = ast.NewSpaceSepList() list.Separator = " " if tok := parser.accept(ast.T_PAREN_OPEN); tok != nil { if sublist := parser.ParseCommaSepList(); sublist != nil { list.Append(sublist) } parser.expect(ast.T_PAREN_CLOSE) } var tok = parser.peek() for tok.Type != ast.T_SEMICOLON && tok.Type != ast.T_BRACE_CLOSE { var subexpr = parser.ParseExpr(true) if subexpr != nil { debug("Parsed Expr: %+v", subexpr) list.Append(subexpr) } else { break } tok = parser.peek() if tok.Type == ast.T_COMMA { break } } debug("Returning space-sep list: %+v", list) if list.Len() == 0 { return nil } else if list.Len() == 1 { return list.Exprs[0] } else if list.Len() > 1 { return list } return nil }