From 84d4bc6f0f38e237f2a40faaf75e921211ab0ac6 Mon Sep 17 00:00:00 2001 From: randomguy3 Date: Sat, 10 Mar 2012 16:16:25 +0000 Subject: Better parse error reporting git-svn-id: https://tikzit.svn.sourceforge.net/svnroot/tikzit/trunk@424 7c02a99a-9b00-45e3-bf44-6f3dd7fddb64 --- tikzit/src/common/TikzGraphAssembler.m | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'tikzit/src/common/TikzGraphAssembler.m') 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 { -- cgit v1.2.3