Ticket #212: tokenizer-error-repeat.patch
File tokenizer-error-repeat.patch, 3.5 KB (added by hopscc, 14 years ago) |
---|
-
Source/Parser.cobra
3 3 var _token as IToken? 4 4 var _fileName as String 5 5 var _lineNum as int 6 var tokenizerError = false 6 7 7 8 cue init(token as IToken, message as String) 8 9 base.init(message) … … 23 24 get hasSourceSite as bool is override 24 25 return true 25 26 27 def consoleString as String is override 28 if .tokenizerError 29 #Tokeniser errors already have source info embedded in msg so just use that 30 return .message 31 return base.consoleString 32 26 33 get fileName from var is override 27 34 28 35 get lineNum from var is override … … 196 203 err = _makeError(token, msg) 197 204 _errorRecorder.recordError(err) 198 205 return err 206 207 def recordTokenError(token as IToken?, msg as String) as ParserException 208 """ 209 Errors from Tokeniser need to be flagged to be treated slightly differently 210 since they already have the source info in their msg. 211 """ 212 err = .recordError(token, msg) 213 err.tokenizerError = true 214 return err 199 215 200 216 def throwError(msg as String) 201 217 .throwError(.last, msg) -
Source/CobraParser.cobra
204 204 Sets up for parsing, but does not invoke `parseTokens`. 205 205 Used by `parseSource` and various test sections. 206 206 Returns true if successful, false if there were one or more errors. 207 Upon success, you can use token methods lik .grab.207 Upon success, you can use token methods like .grab. 208 208 Does not .throwError but may .recordError. 209 209 """ 210 210 _fileName = fileName … … 233 233 else 234 234 _tokens.add(tokens[i]) 235 235 catch te as TokenizerError 236 .record Error(te.token, te.message)236 .recordTokenError(te.token, te.message) 237 237 return false 238 238 239 239 # TODO: fold all occcurrences of this lookup to a helper … … 245 245 246 246 if tokenizer.errors.count 247 247 for error in tokenizer.errors 248 .record Error(error.token, error.message)248 .recordTokenError(error.token, error.message) 249 249 return false 250 250 251 251 _nextTokenIndex = 0 -
Tests/820-errors/100-lexing-and-parsing/105-tokenizer-error-msg.cobra
1 # Test for Tokenizer error giving double print of line no. info: ticket:212 2 # Error line below used to emit 3 # 105-tokenizer-error-msg.cobra(8): error: 105-tokenizer-error-msg.cobra(8,1): error: Space-based indentation must be a multiple of 4. 4 5 class TokenizerError 6 7 # below is wrongly indented only 3 spaces 8 def t #.error. 105-tokenizer-error-msg.cobra(8,1): error: Space-based indentation must be a multiple of 4 9 pass -
Developer/IntermediateReleaseNotes.text
473 473 * Fixed: Only the last `test` of a series of tests is included in the compiler's output. 474 474 475 475 * Fixed: Dynamic binding cannot find `shared` methods. ticket:208 476 477 * Fixed: File, line number and 'error' repeated in compiler error message. ticket:212