@@ -9,7 +9,7 @@ import static dev.webfx.platform.ast.json.parser.javacup.JsonSymbols.*;
99import dev.webfx.platform.util.Numbers ;
1010
1111% %
12-
12+
1313/* -----------------Options and Declarations Section----------------- */
1414
1515%public
@@ -28,17 +28,17 @@ import dev.webfx.platform.util.Numbers;
2828 private Symbol symbol(int type) {
2929 return new Symbol (type, yyline, yycolumn);
3030 }
31-
31+
3232 private Symbol symbol(int type, Object value) {
3333 return new Symbol (type, yyline, yycolumn, value);
3434 }
3535%}
36-
36+
3737
3838/*
3939 Macro Declarations
4040*/
41-
41+
4242LineTerminator = \r|\n|\r\n
4343InputCharacter = [^\r\n]
4444WhiteSpace = {LineTerminator} | [ \t\f]
@@ -60,7 +60,7 @@ Exponent = [eE] [+-]? [0-9]+
6060
6161%%
6262/* ------------------------Lexical Rules Section---------------------- */
63-
63+
6464
6565<YYINITIAL> {
6666
@@ -116,7 +116,13 @@ Exponent = [eE] [+-]? [0-9]+
116116 "\\ r" { string. append( ' \r ' ); }
117117 "\\\" " { string. append( ' \" ' ); }
118118 "\\\\ " { string. append( ' \\ ' ); }
119- \\ . { string. append( yytext() ); }
119+ "\\ /" { string. append( ' /' ); }
120+ "\\ u" [ 0- 9A- Fa- f] {4} {
121+ String hex = yytext(). substring(2 );
122+ int code = Integer . parseInt(hex, 16 );
123+ string. append((char ) code);
124+ }
125+ \\ . { string. append( yytext(). substring(1 ) ); }
120126
121127 /* error cases */
122128 {LineTerminator} { throw new RuntimeException (" Unterminated string at end of line" ); }
@@ -135,7 +141,13 @@ Exponent = [eE] [+-]? [0-9]+
135141 "\\ r" { string. append( ' \r ' ); }
136142 "\\\" " { string. append( ' \" ' ); }
137143 "\\\\ " { string. append( ' \\ ' ); }
138- \\ . { string. append( yytext() ); }
144+ "\\ /" { string. append( ' /' ); }
145+ "\\ u" [ 0- 9A- Fa- f] {4} {
146+ String hex = yytext(). substring(2 );
147+ int code = Integer . parseInt(hex, 16 );
148+ string. append((char ) code);
149+ }
150+ \\ . { string. append( yytext(). substring(1 ) ); }
139151
140152 /* error cases */
141153 {LineTerminator} { throw new RuntimeException (" Unterminated string at end of line" ); }
@@ -154,7 +166,13 @@ Exponent = [eE] [+-]? [0-9]+
154166 "\\ r" { string. append( ' \r ' ); }
155167 "\\\" " { string. append( ' \" ' ); }
156168 "\\\\ " { string. append( ' \\ ' ); }
157- \\ . { string. append( yytext() ); }
169+ "\\ /" { string. append( ' /' ); }
170+ "\\ u" [ 0- 9A- Fa- f] {4} {
171+ String hex = yytext(). substring(2 );
172+ int code = Integer . parseInt(hex, 16 );
173+ string. append((char ) code);
174+ }
175+ \\ . { string. append( yytext(). substring(1 ) ); }
158176
159177 /* error cases */
160178 {LineTerminator} { throw new RuntimeException (" Unterminated string at end of line" ); }
0 commit comments