diff --git a/pmd-objectivec/etc/grammar/ObjC2.0.jj b/pmd-objectivec/etc/grammar/ObjC2.0.jj index 63dca65fa1..ba888ee9ed 100644 --- a/pmd-objectivec/etc/grammar/ObjC2.0.jj +++ b/pmd-objectivec/etc/grammar/ObjC2.0.jj @@ -548,9 +548,19 @@ TOKEN : { } TOKEN : { - < IDENT : ( | )* > + < IDENT : ( | )* > | <#IDENT_NONDIGIT : | > // "may include other implementation-defined characters" -| <#NONDIGIT : ["a"-"z"] | ["A"-"Z"] | "_" | "$" > +| <#NONDIGIT : ["a"-"z"] | ["A"-"Z"] | "_" | "$" | > +| <#NONDIGIT_UNICODE : [ /* source: http://stackoverflow.com/questions/30933785 */ + "\u0024", + "\u0041"-"\u005a", + "\u005f", + "\u0061"-"\u007a", + "\u00c0"-"\u00d6", + "\u00d8"-"\u00f6", + "\u00f8"-"\u00ff", + "\u0100"-"\u1fff" + ] > | <#UNIVERSAL_CHARACTER_NAME : ("\\u" ) | ("\\U" ) > } diff --git a/pmd-objectivec/src/test/java/net/sourceforge/pmd/cpd/UnicodeObjectiveCTokenizerTest.java b/pmd-objectivec/src/test/java/net/sourceforge/pmd/cpd/UnicodeObjectiveCTokenizerTest.java new file mode 100644 index 0000000000..8a58e34179 --- /dev/null +++ b/pmd-objectivec/src/test/java/net/sourceforge/pmd/cpd/UnicodeObjectiveCTokenizerTest.java @@ -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 identifiers with unicode characters +public class UnicodeObjectiveCTokenizerTest extends AbstractTokenizerTest { + + private static final String FILENAME = "NCClient.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 = 10; + super.tokenizeTest(); + } +} diff --git a/pmd-objectivec/src/test/resources/net/sourceforge/pmd/cpd/NCClient.m b/pmd-objectivec/src/test/resources/net/sourceforge/pmd/cpd/NCClient.m new file mode 100644 index 0000000000..d224901507 --- /dev/null +++ b/pmd-objectivec/src/test/resources/net/sourceforge/pmd/cpd/NCClient.m @@ -0,0 +1,5 @@ +@import UIKit; + +static SecCertificateRef gNСServerLogonCertificate; + +@end