Extended Objective-C grammar to accept UTF-8 escapes (\uXXXX) in string literals.
This commit is contained in:
@ -375,8 +375,8 @@ TOKEN : {
|
||||
| <FLOATING_POINT_LITERAL: (["0"-"9"])+ "." (["0"-"9"])* (<EXPONENT>)? (["f","F","d","D"])? | "." (["0"-"9"])+ (<EXPONENT>)? (["f","F","d","D"])? | (["0"-"9"])+ <EXPONENT> (["f","F","d","D"])? | (["0"-"9"])+ (<EXPONENT>)? ["f","F","d","D"]>
|
||||
| <#EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+>
|
||||
| <CHARACTER_LITERAL: "\'" (~["\'","\\","\n","\r"] | "\\" (["n","t","b","r","f","a","v","\\","\'","\""] | ["0"-"7"] (["0"-"7"])? | ["0"-"3"] ["0"-"7"] ["0"-"7"])) "\'">
|
||||
| <STRING_LITERAL: [ "@" ] "\"" ( ~["\"","\\","\n","\r"] | "\\" ["x","X"] (["0"-"9","a"-"f","A"-"F"]) | "\\" ( ["n","t","b","r","f","a","v","\\","\'","\""] | ["0"-"7"] (["0"-"7"])? | ["0"-"3"] ["0"-"7"] ["0"-"7"] | ( ["\n","\r"] | "\r\n")))* "\"">
|
||||
| <CSTRING_LITERAL: "\"" ( ~["\"","\\","\n","\r"] | "\\" ["x","X"] (["0"-"9","a"-"f","A"-"F"]) | "\\" ( ["n","t","b","r","f","a","v","\\","\'","\""] | ["0"-"7"] (["0"-"7"])? | ["0"-"3"] ["0"-"7"] ["0"-"7"] | ( ["\n","\r"] | "\r\n")))* "\"">
|
||||
| <STRING_LITERAL: [ "@" ] "\"" ( ~["\"","\\","\n","\r"] | "\\" ["x","X","u","U"] (["0"-"9","a"-"f","A"-"F"]) | "\\" ( ["n","t","b","r","f","a","v","\\","\'","\""] | ["0"-"7"] (["0"-"7"])? | ["0"-"3"] ["0"-"7"] ["0"-"7"] | ( ["\n","\r"] | "\r\n")))* "\"">
|
||||
| <CSTRING_LITERAL: "\"" ( ~["\"","\\","\n","\r"] | "\\" ["x","X","u","U"] (["0"-"9","a"-"f","A"-"F"]) | "\\" ( ["n","t","b","r","f","a","v","\\","\'","\""] | ["0"-"7"] (["0"-"7"])? | ["0"-"3"] ["0"-"7"] ["0"-"7"] | ( ["\n","\r"] | "\r\n")))* "\"">
|
||||
}
|
||||
|
||||
TOKEN :
|
||||
|
@ -0,0 +1,37 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
package net.sourceforge.pmd.cpd;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.sourceforge.pmd.testframework.AbstractTokenizerTest;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
//Tests if the ObjectiveC tokenizer supports UTF-8 escapes in string literals
|
||||
public class UTF8EscapesInStringLiteralObjCTokenizerTest extends AbstractTokenizerTest {
|
||||
|
||||
private static final String FILENAME = "FileWithUTF8EscapeInStringLiteral.m";
|
||||
|
||||
@Before
|
||||
@Override
|
||||
public void buildTokenizer() throws IOException {
|
||||
this.tokenizer = new ObjectiveCTokenizer();
|
||||
this.sourceCode = new SourceCode(new SourceCode.StringCodeLoader(this.getSampleCode(), FILENAME));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSampleCode() throws IOException {
|
||||
return IOUtils.toString(ObjectiveCTokenizer.class.getResourceAsStream(FILENAME), "UTF-8");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void tokenizeTest() throws IOException {
|
||||
this.expectedTokenCount = 45;
|
||||
super.tokenizeTest();
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
@property (nonatomic, strong) UIButton *copyrightsButton;
|
||||
|
||||
- (void)setupCopyrightsButton {
|
||||
self.copyrightsButton = [[UIButton alloc] initWithFrame:CGRectZero];
|
||||
[self.copyrightsButton setTitle:@"\u00a9" forState:UIControlStateNormal];
|
||||
}
|
||||
|
||||
@end
|
Reference in New Issue
Block a user