Anonymous avatar Anonymous committed 7bbbb6b

Bring Objective C lexer up to date with 2.0 features
(properties and so-called "fast enumerations")

Comments (0)

Files changed (3)

pygments/lexers/compiled.py

             (r'[()\[\],.]', Punctuation),
             (r'(auto|break|case|const|continue|default|do|else|enum|extern|'
              r'for|goto|if|register|restricted|return|sizeof|static|struct|'
-             r'switch|typedef|union|volatile|virtual|while|@selector|'
+             r'switch|typedef|union|volatile|virtual|while|in|@selector|'
              r'@private|@protected|@public|@encode|'
-             r'@synchronized|@try|@throw|@catch|@finally|@end)\b', Keyword),
+             r'@synchronized|@try|@throw|@catch|@finally|@end|@property|'
+             r'@synthesize|@dynamic)\b', Keyword),
             (r'(int|long|float|short|double|char|unsigned|signed|void|'
              r'id|BOOL|IBOutlet|IBAction|SEL)\b', Keyword.Type),
             (r'(_{0,2}inline|naked|restrict|thread|typename)\b', Keyword.Reserved),

tests/examplefiles/objc_example.m

+#import "Somefile.h"
+
+NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:
+    @"quattuor", @"four", @"quinque", @"five", @"sex", @"six", nil];
+
+
+NSString *key;
+for (key in dictionary) {
+    NSLog(@"English: %@, Latin: %@", key, [dictionary valueForKey:key]);
+}
+

tests/examplefiles/objc_example2.m

+// MyClass.h
+@interface MyClass : NSObject
+{
+    NSString *value;
+    NSTextField *textField;
+@private
+    NSDate *lastModifiedDate;
+}
+@property(copy, readwrite) NSString *value;
+@property(retain) IBOutlet NSTextField *textField;
+@end
+
+// MyClass.m
+// Class extension to declare private property
+@interface MyClass ()
+@property(retain) NSDate *lastModifiedDate;
+@end
+
+@implementation MyClass
+@synthesize value;
+@synthesize textField;
+@synthesize lastModifiedDate;
+// implementation continues
+@end
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.