@@ -55,11 +55,6 @@ func New(l *lexer.Lexer, c *config.GenVarsConfig) *Parser {
5555 return p
5656}
5757
58- func (p * Parser ) WithEnvironment (environ []string ) * Parser {
59- p .environ = environ
60- return p
61- }
62-
6358func (p * Parser ) WithLogger (logger log.ILogger ) * Parser {
6459 p .log = nil //speed up GC
6560 p .log = logger
@@ -126,9 +121,6 @@ func (p *Parser) buildConfigManagerTokenFromBlocks(configManagerToken *config.Pa
126121 // built as part of the below parser
127122 sanitizedToken := ""
128123
129- // should exit the loop if no end tag found
130- notFoundEnd := true
131-
132124 // stop on end of file
133125 for ! p .peekTokenIs (config .EOF ) {
134126 // // This is the target state when there is an optional token wrapping
@@ -145,7 +137,6 @@ func (p *Parser) buildConfigManagerTokenFromBlocks(configManagerToken *config.Pa
145137 // when next token is another token
146138 // i.e. the tokens are adjacent
147139 if p .peekTokenIs (config .BEGIN_CONFIGMANAGER_TOKEN ) {
148- notFoundEnd = false
149140 fullToken += p .curToken .Literal
150141 sanitizedToken += p .curToken .Literal
151142 stmt .EndToken = p .curToken
@@ -156,7 +147,6 @@ func (p *Parser) buildConfigManagerTokenFromBlocks(configManagerToken *config.Pa
156147 if p .peekTokenIsEnd () {
157148 // we want set the current token as both the full and sanitized
158149 // the current lexer token is the entire configmanager token
159- notFoundEnd = false
160150 fullToken += p .curToken .Literal
161151 sanitizedToken += p .curToken .Literal
162152 stmt .EndToken = p .curToken
@@ -175,7 +165,6 @@ func (p *Parser) buildConfigManagerTokenFromBlocks(configManagerToken *config.Pa
175165 p .errors = append (p .errors , wrapErr (fullToken , currentToken .Line , currentToken .Column , err ))
176166 return nil
177167 }
178- notFoundEnd = false
179168 // keyPath would have built the keyPath and metadata if any
180169 break
181170 }
@@ -187,7 +176,6 @@ func (p *Parser) buildConfigManagerTokenFromBlocks(configManagerToken *config.Pa
187176 p .errors = append (p .errors , wrapErr (fullToken , currentToken .Line , currentToken .Column , err ))
188177 return nil
189178 }
190- notFoundEnd = false
191179 break
192180 }
193181
@@ -199,18 +187,17 @@ func (p *Parser) buildConfigManagerTokenFromBlocks(configManagerToken *config.Pa
199187 // else it would be lost once the parser is advanced below
200188 p .nextToken ()
201189 if p .peekTokenIs (config .EOF ) {
202- notFoundEnd = false
203190 fullToken += p .curToken .Literal
204191 sanitizedToken += p .curToken .Literal
205192 stmt .EndToken = p .curToken
206193 break
207194 }
208195 }
209196
210- if notFoundEnd {
211- p .errors = append (p .errors , wrapErr (fullToken , currentToken .Line , currentToken .Column , ErrNoEndTagFound ))
212- return nil
213- }
197+ // if notFoundEnd {
198+ // p.errors = append(p.errors, wrapErr(fullToken, currentToken.Line, currentToken.Column, ErrNoEndTagFound))
199+ // return nil
200+ // }
214201
215202 configManagerToken .WithSanitizedToken (sanitizedToken )
216203 stmt .ParsedToken = * configManagerToken
@@ -269,13 +256,8 @@ func (p *Parser) buildMetadata(configManagerToken *config.ParsedTokenConfig) err
269256 p .nextToken ()
270257 for ! p .peekTokenIs (config .EOF ) {
271258 if p .peekTokenIsEnd () {
272- if p .currentTokenIs (config .END_META_CONFIGMANAGER_TOKEN ) {
273- metadata += p .curToken .Literal
274- found = true
275- p .nextToken ()
276- break
277- }
278- return fmt .Errorf ("%w, metadata string has no closing" , ErrNoEndTagFound )
259+ // next token is an end of token but no closing `]` found
260+ return fmt .Errorf ("%w, metadata (%s) string has no closing" , ErrNoEndTagFound , metadata )
279261 }
280262 if p .peekTokenIs (config .END_META_CONFIGMANAGER_TOKEN ) {
281263 metadata += p .curToken .Literal
@@ -289,6 +271,7 @@ func (p *Parser) buildMetadata(configManagerToken *config.ParsedTokenConfig) err
289271 configManagerToken .WithMetadata (metadata )
290272
291273 if ! found {
274+ // hit the end of file and no end tag found
292275 return fmt .Errorf ("%w, metadata string has no closing" , ErrNoEndTagFound )
293276 }
294277 return nil
0 commit comments