New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from Feb 24, 2016

Conversation

Projects
None yet
2 participants
@tiobe

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

This comment has been minimized.

Show comment
Hide comment
@adangel

adangel Feb 24, 2016

Owner

Thanks!

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