diff options
author | randomguy3 <randomguy3@7c02a99a-9b00-45e3-bf44-6f3dd7fddb64> | 2012-03-10 16:16:25 +0000 |
---|---|---|
committer | randomguy3 <randomguy3@7c02a99a-9b00-45e3-bf44-6f3dd7fddb64> | 2012-03-10 16:16:25 +0000 |
commit | 84d4bc6f0f38e237f2a40faaf75e921211ab0ac6 (patch) | |
tree | d3a644fed47ea2b24cf6c9a50480bd766f036bc9 /tikzit/src/common/TikzGraphAssembler.m | |
parent | 4f15081a2cdf33c1ec6ba8c3c90ae81a7d4b42e8 (diff) |
Better parse error reporting
git-svn-id: https://tikzit.svn.sourceforge.net/svnroot/tikzit/trunk@424 7c02a99a-9b00-45e3-bf44-6f3dd7fddb64
Diffstat (limited to 'tikzit/src/common/TikzGraphAssembler.m')
-rw-r--r-- | tikzit/src/common/TikzGraphAssembler.m | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/tikzit/src/common/TikzGraphAssembler.m b/tikzit/src/common/TikzGraphAssembler.m index 5354710..5e60b05 100644 --- a/tikzit/src/common/TikzGraphAssembler.m +++ b/tikzit/src/common/TikzGraphAssembler.m @@ -22,6 +22,7 @@ // #import "TikzGraphAssembler.h" +#import "NSError+Tikzit.h" extern int yyparse(void); extern int yylex(void); @@ -36,7 +37,10 @@ static id currentAssembler = nil; void yyerror(const char *str) { NSLog(@"Parse error: %s", str); if (currentAssembler != nil) { - [currentAssembler invalidate]; + NSError *error = [NSError + errorWithMessage:[NSString stringWithCString:str] + code:TZ_ERR_PARSE]; + [currentAssembler invalidateWithError:error]; } } @@ -56,6 +60,7 @@ int yywrap() { } - (Graph*)graph { return graph; } +- (NSError*)lastError { return lastError; } - (GraphElementData *)data { if (currentNode != nil) { @@ -95,6 +100,7 @@ int yywrap() { yylex_destroy(); [nodeMap release]; + nodeMap = nil; currentAssembler = nil; [pool drain]; @@ -144,12 +150,19 @@ int yywrap() { - (void)dealloc { [graph release]; + [lastError release]; [super dealloc]; } - (void)invalidate { [graph release]; graph = nil; + lastError = nil; +} + +- (void)invalidateWithError:(NSError*)error { + [self invalidate]; + lastError = [error retain]; } + (void)setup { |