[objectivec] Extended Objective-C grammar to accept UTF-8 escapes (\uXXXX) in string literals. #32

Merged
merged 1 commit into from Feb 24, 2016

Projects

None yet

2 participants

@tiobe
Contributor
tiobe commented Feb 18, 2016
Extended Objective-C grammar to accept UTF-8 escapes (\uXXXX) in string literals.

The Objective-C tokenizer cannot handle UTF-8 escapes (\uXXXX) in string literals. Tokenizing the following code:

@property (nonatomic, strong) UIButton *copyrightsButton;

- (void)setupCopyrightsButton {
    self.copyrightsButton = [[UIButton alloc] initWithFrame:CGRectZero];
    [self.copyrightsButton setTitle:@"\u00a9" forState:UIControlStateNormal];
}

@end

throws the following exception:

net.sourceforge.pmd.lang.ast.TokenMgrError: Lexical error in file FileWithUTF8EscapeInStringLiteral.m at line 5, column 40.  Encountered: "u" (117), after : "\"\\"
        at net.sourceforge.pmd.lang.objectivec.ast.ObjectiveCParserTokenManager.getNextToken(ObjectiveCParserTokenManager.java:6354)
        at net.sourceforge.pmd.lang.objectivec.ObjectiveCTokenManager.getNextToken(ObjectiveCTokenManager.java:27)
        at net.sourceforge.pmd.cpd.ObjectiveCTokenizer.tokenize(ObjectiveCTokenizer.java:36)

This pull request fixes this problem.

@adangel
Owner
adangel commented Feb 24, 2016

Thanks!

@adangel adangel merged commit 7915f08 into adangel:pmd/5.3.x Feb 24, 2016
@adangel adangel changed the title from Extended Objective-C grammar to accept UTF-8 escapes (\uXXXX) in string literals. to [objectivec] Extended Objective-C grammar to accept UTF-8 escapes (\uXXXX) in string literals. Jun 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment