@ -491,7 +491,8 @@ TOKEN_MGR_DECLS :
|
||||
|
||||
SPECIAL_TOKEN :
|
||||
{
|
||||
" " | "\t" | "\n" | "\r" | "\f"
|
||||
< HORIZONTAL_WHITESPACE: [" ", "\t", "\f"] >
|
||||
| < LINE_TERMINATOR: "\n" | "\r" | "\r\n" >
|
||||
}
|
||||
|
||||
SPECIAL_TOKEN :
|
||||
@ -655,34 +656,28 @@ TOKEN :
|
||||
)
|
||||
"'"
|
||||
>
|
||||
| < #STRING_ESCAPE:
|
||||
"\\"
|
||||
( ["n","t","b","r","f","\\","'","\""]
|
||||
// octal escapes
|
||||
| ["0"-"7"] ( ["0"-"7"] )?
|
||||
| ["0"-"3"] ["0"-"7"] ["0"-"7"]
|
||||
)
|
||||
>
|
||||
|
|
||||
< STRING_LITERAL:
|
||||
"\""
|
||||
( (~["\"","\\","\n","\r"])
|
||||
| ("\\"
|
||||
( ["n","t","b","r","f","\\","'","\""]
|
||||
| ["0"-"7"] ( ["0"-"7"] )?
|
||||
| ["0"-"3"] ["0"-"7"] ["0"-"7"]
|
||||
)
|
||||
)
|
||||
| <STRING_ESCAPE>
|
||||
)*
|
||||
"\""
|
||||
>
|
||||
}
|
||||
|
||||
MORE :
|
||||
{
|
||||
< "\"\"\"" > : IN_TEXT_BLOCK
|
||||
}
|
||||
|
||||
<IN_TEXT_BLOCK> TOKEN :
|
||||
{
|
||||
< TEXT_BLOCK_LITERAL: "\"\"\""> : DEFAULT
|
||||
}
|
||||
|
||||
<IN_TEXT_BLOCK> MORE :
|
||||
{
|
||||
< ~[] >
|
||||
|
|
||||
< TEXT_BLOCK_LITERAL:
|
||||
"\"\"\"" (<HORIZONTAL_WHITESPACE>)* <LINE_TERMINATOR>
|
||||
( ~["\"", "\\"] | "\"" ~["\""] | "\"\"" ~["\""] | <STRING_ESCAPE> )*
|
||||
"\"\"\""
|
||||
>
|
||||
}
|
||||
|
||||
/* IDENTIFIERS */
|
||||
|
@ -74,7 +74,7 @@ public class Java13Test {
|
||||
ASTCompilationUnit compilationUnit = ParserTstUtil.parseAndTypeResolveJava("13", loadSource("TextBlocks.java"));
|
||||
Assert.assertNotNull(compilationUnit);
|
||||
List<ASTLiteral> literals = compilationUnit.findDescendantsOfType(ASTLiteral.class);
|
||||
Assert.assertEquals(9, literals.size());
|
||||
Assert.assertEquals(10, literals.size());
|
||||
for (int i = 0; i < 8; i++) {
|
||||
ASTLiteral literal = literals.get(i);
|
||||
Assert.assertTrue(literal.isTextBlock());
|
||||
@ -83,6 +83,7 @@ public class Java13Test {
|
||||
+ " <p>Hello, world</p>\n" + " </body>\n"
|
||||
+ " </html>\n" + " \"\"\"", literals.get(0).getImage());
|
||||
Assert.assertFalse(literals.get(8).isTextBlock());
|
||||
Assert.assertTrue(literals.get(9).isTextBlock());
|
||||
}
|
||||
|
||||
@Test(expected = ParseException.class)
|
||||
|
@ -44,5 +44,12 @@ public class TextBlocks {
|
||||
"""; // the two characters \ LF
|
||||
|
||||
String normalStringLiteral = "test";
|
||||
|
||||
String code =
|
||||
"""
|
||||
String text = \"""
|
||||
A text block inside a text block
|
||||
\""";
|
||||
""";
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user