diff options
author | Alex Merry <dev@randomguy3.me.uk> | 2013-03-23 03:30:19 +0000 |
---|---|---|
committer | Alex Merry <dev@randomguy3.me.uk> | 2013-03-23 03:38:55 +0000 |
commit | 8cde489ab6c4169fb03d810447c18eea0d0eaa14 (patch) | |
tree | ad3fcdc71f1819963198ae8a52fc5f2b2818cd20 /tikzit/src/osx/TikzSourceController.m | |
parent | e68a44b882e5d6dbbab769f7ef20355ec53a9278 (diff) |
Make the parser/lexer reentrant
No more locking! Also, the interface for TikzGraphAssembler is much
simpler.
Changes to OSX code are completely untested.
Diffstat (limited to 'tikzit/src/osx/TikzSourceController.m')
-rw-r--r-- | tikzit/src/osx/TikzSourceController.m | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/tikzit/src/osx/TikzSourceController.m b/tikzit/src/osx/TikzSourceController.m index d05aa41..d01589b 100644 --- a/tikzit/src/osx/TikzSourceController.m +++ b/tikzit/src/osx/TikzSourceController.m @@ -22,6 +22,7 @@ // #import "TikzSourceController.h" +#import "TikzGraphAssembler.h" #import "Graph.h" @implementation TikzSourceController @@ -82,8 +83,6 @@ - (void)awakeFromNib { justUndid = NO; - assembler = [[TikzGraphAssembler alloc] init]; - successColor = [NSColor colorWithCalibratedRed:0.0f green:0.5f blue:0.0f @@ -143,11 +142,12 @@ } - (BOOL)tryParseTikz { - BOOL success = [assembler parseTikz:[self tikz]]; + Graph *g = [TikzGraphAssembler parseTikz:[self tikz] + error:&lastError]; - if (success) { + if (g) { [graphicsView deselectAll:self]; - [graphicsView setGraph:[assembler graph]]; + [graphicsView setGraph:g]; [graphicsView refreshLayers]; [self doRevertTikz]; } @@ -181,7 +181,7 @@ [status setStringValue:@"parse error"]; [status setTextColor:failedColor]; - NSDictionary *d = [[assembler lastError] userInfo]; + NSDictionary *d = [lastError userInfo]; NSString *ts = [NSString stringWithFormat: @"Parse error on line %@: %@\n", [d valueForKey:@"lineNumber"], [d valueForKey:NSLocalizedDescriptionKey]]; NSMutableAttributedString *as = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat: @"Parse error on line %@: %@\n%@\n", [d valueForKey:@"lineNumber"], [d valueForKey:NSLocalizedDescriptionKey], [[d valueForKey:@"syntaxString"] stringByReplacingOccurrencesOfString:@"\t" withString:@""]]]; |