Skip to content

Commit cfcdeb8

Browse files
authored
Merge pull request #375 from DineshSolanki/fix/373-non-ascii-parse
fix: #373 - Enhance identifier parsing to support Unicode characters
2 parents 763ba62 + 85bea56 commit cfcdeb8

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

core/src/main/jjtree/jslt.jjt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,11 @@ TOKEN :
6969
< DEF: "def" > |
7070
< IMPORT: "import" > |
7171
< AS: "as" > |
72-
< IDENT: (["A"-"Z"] | ["a"-"z"] | ["0"-"9"] | "_" | "-")+ > |
73-
< PIDENT:
74-
(["A"-"Z"] | ["a"-"z"] | ["0"-"9"] | "_" | "-")+
75-
":"
76-
(["A"-"Z"] | ["a"-"z"] | ["0"-"9"] | "_" | "-")+
77-
> |
78-
< VARIABLE: "$" (["A"-"Z"] | ["a"-"z"] | ["0"-"9"] | "_" | "-")+ >
72+
< #IDENT_CHARS: ["A"-"Z", "a"-"z", "0"-"9", "_", "-", "\u0080"-"\uffff"] > |
73+
74+
< IDENT: (<IDENT_CHARS>)+ > |
75+
< PIDENT: (<IDENT_CHARS>)+ ":" (<IDENT_CHARS>)+ > |
76+
< VARIABLE: "$" (<IDENT_CHARS>)+ >
7977
}
8078

8179
// http://www.engr.mun.ca/~theo/JavaCC-FAQ/javacc-faq-moz.htm#tth_sEc3.15

core/src/test/java/com/schibsted/spt/data/jslt/TemplateTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11

22
package com.schibsted.spt.data.jslt;
33

4-
import java.io.IOException;
54
import org.junit.Test;
6-
import static org.junit.Assert.fail;
7-
import static org.junit.Assert.assertTrue;
8-
import static org.junit.Assert.assertEquals;
9-
10-
import com.fasterxml.jackson.databind.JsonNode;
11-
import com.fasterxml.jackson.databind.ObjectMapper;
12-
import com.fasterxml.jackson.databind.node.NullNode;
135

146
/**
157
* Test cases verifying templates.
@@ -380,4 +372,12 @@ public void testDynamicKeys() {
380372
load("cdp.json"));
381373
}
382374

375+
@Test
376+
public void testUnicodeIdentifierParsing() {
377+
String input = " {\"mypropé\" : \"w23q7ca1-8729-24923-922b-1c0517ddffjf1\", \"type\" : \"View\"} ";
378+
String jslt = "{\"id\" : .mypropé, \"type\" : \"Anonymized-View\"} ";
379+
String result = "{\"id\" : \"w23q7ca1-8729-24923-922b-1c0517ddffjf1\",\"type\" : \"Anonymized-View\"} ";
380+
check(input, jslt, result);
381+
}
382+
383383
}

0 commit comments

Comments
 (0)