(startingSection *Section, period bool)
| 109 | } |
| 110 | |
| 111 | func (parser *Parser) parseReference(startingSection *Section, period bool) (Value, error) { |
| 112 | name := "" |
| 113 | if period == false { |
| 114 | name = parser.curTok.Literal |
| 115 | } |
| 116 | for { |
| 117 | parser.readToken() |
| 118 | if parser.curTok.ID == token.PERIOD && period == false { |
| 119 | period = true |
| 120 | } else if period && parser.curTok.ID == token.IDENTIFIER { |
| 121 | if len(name) > 0 { |
| 122 | name += "." |
| 123 | } |
| 124 | name += parser.curTok.Literal |
| 125 | period = false |
| 126 | } else if isSemicolonOrNewline(parser.curTok.ID) { |
| 127 | break |
| 128 | } else { |
| 129 | msg := fmt.Sprintf("expected ';' or '\n' instead found '%s'", parser.curTok.Literal) |
| 130 | return nil, parser.syntaxError(msg) |
| 131 | } |
| 132 | } |
| 133 | if len(name) == 0 { |
| 134 | return nil, parser.syntaxError( |
| 135 | fmt.Sprintf("expected IDENTIFIER instead found %s", parser.curTok.Literal), |
| 136 | ) |
| 137 | } |
| 138 | |
| 139 | if period { |
| 140 | return nil, parser.syntaxError(fmt.Sprintf("expected IDENTIFIER after PERIOD")) |
| 141 | } |
| 142 | |
| 143 | return NewReference(name, startingSection), nil |
| 144 | } |
| 145 | |
| 146 | func (parser *Parser) parseSettingValue() (Value, error) { |
| 147 | var value Value |
no test coverage detected