Objective-C 2.0 grammars with preprocessor support can be used in 2 different modes:
- One-step processing. Includes a lexer which is used for both directives and ordinary Objective-C code. Used in Swiftify Objective-C to Swift converter.
- Two-step processing. Includes separate lexers for directives and Objective-C code. Used in Codebeat, the web service for automated code review for different programming languages (including Objective-C).
- Lexer (ObjectiveCLexer.g4).
- Parser (ObjectiveCPreprocessorParser.g4 and ObjectiveCParser.g4).
- Preprocessor lexer (ObjectiveCPreprocessorLexer.g4).
- Preprocessor parser (ObjectiveCPreprocessorLexer.g4).
- Visitor class for removing preprocessor directives from code (ObjectiveCPreprocessor.java).
- Lexer (ObjectiveCLexer.g4).
- Parser (ObjectiveCParser.g4).
ObjectiveCPreprocessor
processes preprocessor directives and replaces code
that does not compile with spaces.
Spaces are kept for correct detection of error line and column numbers
during parsing of the ordinary Objective-C code.
ObjectiveCParser
is shared by both one-step and two-step processing.
Successful parsing and conversion of complete projects, ex. Popovers demo.
More than 95% correctly parsed .m files from these projects:
- AFNetworking
- realm-cocoa
- iOS-Source-Code-Analyze
- SDWebImage
- MJRefresh
- SmarterStreaming
- ReactiveCocoa
- GSKStretchyHeaderView
- JSQMessagesViewController
- SocketRocket
- MBProgressHUD
- DZNEmptyDataSet
- AsyncDisplayKit
- UITableView-FDTemplateLayoutCell3
- SDAutoLayout
- Chameleon
- TomatoRead
- iCarousel
- SVProgressHUD
- fmdb
ObjectiveC grammars and helper files are licensed under MIT.