Skip to content

Commit

Permalink
fix parsing multiline strings in jass
Browse files Browse the repository at this point in the history
fix was only in jurst grammar
  • Loading branch information
Frotty committed Jan 15, 2020
1 parent c8b3a7e commit 04f2567
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ JASS_ELSEIF: 'elseif';
NL: [\r\n]+;
ID: [a-zA-Z_][a-zA-Z0-9_]* ;

STRING: '"' ( EscapeSequence | ~('\\'|'"'|'\r'|'\n') )* '"';
STRING: '"' ( EscapeSequence | ~('\\'|'"'|'\r'|'\n') | NL )* '"';
REAL: [0-9]+ '.' [0-9]* | '.'[0-9]+;

fragment HexInt: '$'[0-9a-fA-F]+ | '0'[xX][0-9a-fA-F]+;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,35 @@ public void returnDetection() { // #641
testJurstWithJass(true, false, jassCode, jurstCode);
}

@Test
public void jassMultilineString() {
String jassCode =
"function bar takes string s returns nothing\r" +
"endfunction\r" +
"function foo takes integer a returns integer\r" +
" call bar(\"Bla\r" +
"string continues\")\r" +
" if false then\r" +
" return a\r" +
" else\r" +
" return -a\r" +
" endif\r" +
"endfunction\r";


String jurstCode = Utils.string(
"package test",
" native testSuccess()",
" init",
" if foo(1) == -1",
" testSuccess()",
" end",
" end",
"endpackage");

testJurstWithJass(true, false, jassCode, jurstCode);
}

@Test
public void testBigJassScript() throws IOException {
String jassCode = new String(Files.readAllBytes(Paths.get(Utils.getResourceFile("test.j"))));
Expand Down

0 comments on commit 04f2567

Please sign in to comment.