| 11 | } |
| 12 | |
| 13 | parse(): Record<string, string> { |
| 14 | const result: Record<string, string> = {}; |
| 15 | |
| 16 | while (this.pos < this.tokens.length) { |
| 17 | const token = this.current(); |
| 18 | |
| 19 | // Skip comments |
| 20 | if ( |
| 21 | token.type === TokenType.COMMENT_SINGLE || |
| 22 | token.type === TokenType.COMMENT_MULTI |
| 23 | ) { |
| 24 | this.advance(); |
| 25 | continue; |
| 26 | } |
| 27 | |
| 28 | // End of file |
| 29 | if (token.type === TokenType.EOF) { |
| 30 | break; |
| 31 | } |
| 32 | |
| 33 | // Expect entry: STRING "=" STRING ";" |
| 34 | if (token.type === TokenType.STRING) { |
| 35 | const entry = this.parseEntry(); |
| 36 | if (entry) { |
| 37 | result[entry.key] = entry.value; |
| 38 | } |
| 39 | continue; |
| 40 | } |
| 41 | |
| 42 | // Skip unexpected tokens gracefully |
| 43 | this.advance(); |
| 44 | } |
| 45 | |
| 46 | return result; |
| 47 | } |
| 48 | |
| 49 | private parseEntry(): { key: string; value: string } | null { |
| 50 | // Current token should be STRING (key) |