Dictionary parsing functions
(pos Pos)
| 2010 | // Dictionary parsing functions |
| 2011 | |
| 2012 | func (p *Parser) parseDictionarySchemaClause(pos Pos) (*DictionarySchemaClause, error) { |
| 2013 | if err := p.expectTokenKind(TokenKindLParen); err != nil { |
| 2014 | return nil, err |
| 2015 | } |
| 2016 | |
| 2017 | schema := &DictionarySchemaClause{ |
| 2018 | SchemaPos: pos, |
| 2019 | } |
| 2020 | |
| 2021 | // Parse first attribute |
| 2022 | attr, err := p.parseDictionaryAttribute(p.Pos()) |
| 2023 | if err != nil { |
| 2024 | return nil, err |
| 2025 | } |
| 2026 | schema.Attributes = append(schema.Attributes, attr) |
| 2027 | |
| 2028 | // Parse additional attributes |
| 2029 | for p.tryConsumeTokenKind(TokenKindComma) != nil { |
| 2030 | attr, err := p.parseDictionaryAttribute(p.Pos()) |
| 2031 | if err != nil { |
| 2032 | return nil, err |
| 2033 | } |
| 2034 | schema.Attributes = append(schema.Attributes, attr) |
| 2035 | } |
| 2036 | |
| 2037 | rParenPos := p.Pos() |
| 2038 | if err := p.expectTokenKind(TokenKindRParen); err != nil { |
| 2039 | return nil, err |
| 2040 | } |
| 2041 | schema.RParenPos = rParenPos |
| 2042 | |
| 2043 | return schema, nil |
| 2044 | } |
| 2045 | |
| 2046 | func (p *Parser) parseDictionaryAttribute(pos Pos) (*DictionaryAttribute, error) { |
| 2047 | name, err := p.parseIdent() |
no test coverage detected