Skip to content

Commit

Permalink
Merge pull request #8 from GuntherRademacher/rename-implicit-tokens
Browse files Browse the repository at this point in the history
Rename implicit tokens
  • Loading branch information
GuntherRademacher authored Dec 26, 2024
2 parents b2f50aa + ce6ea93 commit 23e1942
Show file tree
Hide file tree
Showing 131 changed files with 4,279 additions and 4,241 deletions.
6 changes: 3 additions & 3 deletions rex-tests/src/test/java/de/bottlecaps/rex/test/base/Pass.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ public static void passEarlyIfPossible(Runner runner, String fileName)
File cacheFile = new File(cachePath + fileName);
if (cacheFile.exists())
{
if (isSameCode(content, Paths.get(cacheFile.getCanonicalPath())))
String cacheContent = new NamedFile(Paths.get(cacheFile.getCanonicalPath())).getContent();
if (isSameCode(content, cacheContent))
{
runner.cleanup();
throw new Pass(cachePath);
Expand All @@ -113,9 +114,8 @@ public static void passEarlyIfPossible(Runner runner, String fileName)
Pass.content = content;
}

public static boolean isSameCode(String code1, Path path)
public static boolean isSameCode(String code1, String code2)
{
String code2 = new NamedFile(path).getContent();
return code2.replaceFirst("This file was generated[^\n]+\n", "").equals(
code1.replaceFirst("This file was generated[^\n]+\n", ""));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

public class TestRemake extends AbstractSinglePlatformTest
{
private static boolean runningInEclipse = isEclipseRunnerInStackTrace();

public static Collection<String> testRemake() throws IOException {
String suffix = ".ref";
List<String> filenames = new ArrayList<>();
Expand Down Expand Up @@ -84,8 +86,22 @@ public void testRemake(String fileName)

runner.compile(fileName);

if (! Pass.isSameCode(expectedContent, runner.getPath(fileName)))
Assertions.fail(runner.summary("actual result does not match expected result from " + expectedResult.getPath()));
String actualContent = new NamedFile(runner.getPath(fileName)).getContent();
if (! Pass.isSameCode(expectedContent, actualContent)) {
String summary = runner.summary(
"actual result does not match expected result, see\n"
+ " diff " + runner.getPath(fileName) + " " + expectedResult.getPath());
if (runningInEclipse)
{
// when running in Eclipse test runner, show the complete diff
Assertions.assertEquals(expectedContent, actualContent, summary);
}
else
{
// otherwise, show just the diff command
Assertions.fail(summary);
}
}

Pass.passNormally(runner);
});
Expand All @@ -108,4 +124,13 @@ private String rexCommandLine(String content) {
return "";
}

private static boolean isEclipseRunnerInStackTrace()
{
for (StackTraceElement element : Thread.currentThread().getStackTrace())
{
if (element.getClassName().startsWith("org.eclipse.jdt.internal.junit.runner"))
return true;
}
return false;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated on Sun Jun 6, 2021 17:04 (UTC+02) by REx v5.53 which is Copyright (c) 1979-2021 by Gunther Rademacher <grd@gmx.net>
// This file was generated on Thu Dec 26, 2024 06:54 (UTC+01) by REx v6.1-SNAPSHOT which is Copyright (c) 1979-2024 by Gunther Rademacher <grd@gmx.net>
// REx command line: -q CR-xquery-31-20141218.ebnf -java -performance

public class CR_xquery_31_20141218
Expand Down Expand Up @@ -9739,7 +9739,7 @@ public class CR_xquery_31_20141218

private static final String[] TOKEN =
{
"(0)",
"%ERROR",
"IntegerLiteral",
"DecimalLiteral",
"DoubleLiteral",
Expand Down
64 changes: 33 additions & 31 deletions rex-tests/src/test/resources/output/EcmaScript.java.ref
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated on Fri Dec 2, 2022 17:59 (UTC+01) by REx v5.55 which is Copyright (c) 1979-2022 by Gunther Rademacher <grd@gmx.net>
// This file was generated on Wed Dec 25, 2024 22:26 (UTC+01) by REx v6.1-SNAPSHOT which is Copyright (c) 1979-2024 by Gunther Rademacher <grd@gmx.net>
// REx command line: -q EcmaScript.ebnf -ll 1 -backtrack -asi -java -performance -saxon -tree

import java.util.Arrays;
Expand Down Expand Up @@ -975,7 +975,7 @@ public class EcmaScript
{
eventHandler.startNonterminal("VariableDeclaration", e0);
consume(4); // Identifier
lookahead1W(18); // END | EOF | WhiteSpace | Comment | ',' | ';' | '=' | '}'
lookahead1W(18); // %OTHER | EOF | WhiteSpace | Comment | ',' | ';' | '=' | '}'
if (l1 == 43) // '='
{
whitespace();
Expand All @@ -987,7 +987,7 @@ public class EcmaScript
private void try_VariableDeclaration()
{
consumeT(4); // Identifier
lookahead1W(18); // END | EOF | WhiteSpace | Comment | ',' | ';' | '=' | '}'
lookahead1W(18); // %OTHER | EOF | WhiteSpace | Comment | ',' | ';' | '=' | '}'
if (l1 == 43) // '='
{
try_Initialiser();
Expand Down Expand Up @@ -1687,9 +1687,10 @@ public class EcmaScript
parse_UnaryExpression();
for (;;)
{
lookahead1W(27); // END | EOF | WhiteSpace | Comment | '!=' | '!==' | '%' | '&' | '&&' | ')' | '*' |
// '+' | ',' | '-' | '/' | ':' | ';' | '<' | '<<' | '<=' | '==' | '===' | '>' |
// '>=' | '>>' | '>>>' | '?' | ']' | '^' | 'in' | 'instanceof' | '|' | '||' | '}'
lookahead1W(27); // %OTHER | EOF | WhiteSpace | Comment | '!=' | '!==' | '%' | '&' | '&&' | ')' |
// '*' | '+' | ',' | '-' | '/' | ':' | ';' | '<' | '<<' | '<=' | '==' | '===' |
// '>' | '>=' | '>>' | '>>>' | '?' | ']' | '^' | 'in' | 'instanceof' | '|' | '||' |
// '}'
if (l1 != 18 // '%'
&& l1 != 25 // '*'
&& l1 != 35) // '/'
Expand Down Expand Up @@ -1723,9 +1724,10 @@ public class EcmaScript
try_UnaryExpression();
for (;;)
{
lookahead1W(27); // END | EOF | WhiteSpace | Comment | '!=' | '!==' | '%' | '&' | '&&' | ')' | '*' |
// '+' | ',' | '-' | '/' | ':' | ';' | '<' | '<<' | '<=' | '==' | '===' | '>' |
// '>=' | '>>' | '>>>' | '?' | ']' | '^' | 'in' | 'instanceof' | '|' | '||' | '}'
lookahead1W(27); // %OTHER | EOF | WhiteSpace | Comment | '!=' | '!==' | '%' | '&' | '&&' | ')' |
// '*' | '+' | ',' | '-' | '/' | ':' | ';' | '<' | '<<' | '<=' | '==' | '===' |
// '>' | '>=' | '>>' | '>>>' | '?' | ']' | '^' | 'in' | 'instanceof' | '|' | '||' |
// '}'
if (l1 != 18 // '%'
&& l1 != 25 // '*'
&& l1 != 35) // '/'
Expand Down Expand Up @@ -2170,7 +2172,7 @@ public class EcmaScript
}
for (;;)
{
lookahead1W(36); // END | EOF | WhiteSpace | Comment | '!=' | '!==' | '%' | '%=' | '&' | '&&' |
lookahead1W(36); // %OTHER | EOF | WhiteSpace | Comment | '!=' | '!==' | '%' | '%=' | '&' | '&&' |
// '&=' | '(' | ')' | '*' | '*=' | '+' | '++' | '+=' | ',' | '-' | '--' | '-=' |
// '.' | '/' | '/=' | ':' | ';' | '<' | '<<' | '<<=' | '<=' | '=' | '==' | '===' |
// '>' | '>=' | '>>' | '>>=' | '>>>' | '>>>=' | '?' | '[' | ']' | '^' | '^=' |
Expand Down Expand Up @@ -2224,7 +2226,7 @@ public class EcmaScript
}
for (;;)
{
lookahead1W(36); // END | EOF | WhiteSpace | Comment | '!=' | '!==' | '%' | '%=' | '&' | '&&' |
lookahead1W(36); // %OTHER | EOF | WhiteSpace | Comment | '!=' | '!==' | '%' | '%=' | '&' | '&&' |
// '&=' | '(' | ')' | '*' | '*=' | '+' | '++' | '+=' | ',' | '-' | '--' | '-=' |
// '.' | '/' | '/=' | ':' | ';' | '<' | '<<' | '<<=' | '<=' | '=' | '==' | '===' |
// '>' | '>=' | '>>' | '>>=' | '>>>' | '>>>=' | '?' | '[' | ']' | '^' | '^=' |
Expand Down Expand Up @@ -3130,7 +3132,7 @@ public class EcmaScript
parse_Arguments();
for (;;)
{
lookahead1W(36); // END | EOF | WhiteSpace | Comment | '!=' | '!==' | '%' | '%=' | '&' | '&&' |
lookahead1W(36); // %OTHER | EOF | WhiteSpace | Comment | '!=' | '!==' | '%' | '%=' | '&' | '&&' |
// '&=' | '(' | ')' | '*' | '*=' | '+' | '++' | '+=' | ',' | '-' | '--' | '-=' |
// '.' | '/' | '/=' | ':' | ';' | '<' | '<<' | '<<=' | '<=' | '=' | '==' | '===' |
// '>' | '>=' | '>>' | '>>=' | '>>>' | '>>>=' | '?' | '[' | ']' | '^' | '^=' |
Expand Down Expand Up @@ -3174,7 +3176,7 @@ public class EcmaScript
try_Arguments();
for (;;)
{
lookahead1W(36); // END | EOF | WhiteSpace | Comment | '!=' | '!==' | '%' | '%=' | '&' | '&&' |
lookahead1W(36); // %OTHER | EOF | WhiteSpace | Comment | '!=' | '!==' | '%' | '%=' | '&' | '&&' |
// '&=' | '(' | ')' | '*' | '*=' | '+' | '++' | '+=' | ',' | '-' | '--' | '-=' |
// '.' | '/' | '/=' | ':' | ';' | '<' | '<<' | '<<=' | '<=' | '=' | '==' | '===' |
// '>' | '>=' | '>>' | '>>=' | '>>>' | '>>>=' | '?' | '[' | ']' | '^' | '^=' |
Expand Down Expand Up @@ -3635,7 +3637,7 @@ public class EcmaScript
whitespace();
parse_Expression();
consume(24); // ')'
lookahead1W(15); // END | EOF | WhiteSpace | Comment | ';' | '}'
lookahead1W(15); // %OTHER | EOF | WhiteSpace | Comment | ';' | '}'
whitespace();
parse_Semicolon();
break;
Expand Down Expand Up @@ -3972,7 +3974,7 @@ public class EcmaScript
// '~'
try_Expression();
consumeT(24); // ')'
lookahead1W(15); // END | EOF | WhiteSpace | Comment | ';' | '}'
lookahead1W(15); // %OTHER | EOF | WhiteSpace | Comment | ';' | '}'
try_Semicolon();
break;
case -3:
Expand Down Expand Up @@ -4869,7 +4871,7 @@ public class EcmaScript
{
eventHandler.startNonterminal("ContinueStatement", e0);
consume(60); // 'continue'
lookahead1W(17); // END | EOF | Identifier | WhiteSpace | Comment | ';' | '}'
lookahead1W(17); // %OTHER | EOF | Identifier | WhiteSpace | Comment | ';' | '}'
if (l1 != 38 && l1 >= 0 && followsLineTerminator()) // ';'
{
l1 = 38; // ';'
Expand All @@ -4880,7 +4882,7 @@ public class EcmaScript
{
consume(4); // Identifier
}
lookahead1W(15); // END | EOF | WhiteSpace | Comment | ';' | '}'
lookahead1W(15); // %OTHER | EOF | WhiteSpace | Comment | ';' | '}'
whitespace();
parse_Semicolon();
eventHandler.endNonterminal("ContinueStatement", e0);
Expand All @@ -4889,7 +4891,7 @@ public class EcmaScript
private void try_ContinueStatement()
{
consumeT(60); // 'continue'
lookahead1W(17); // END | EOF | Identifier | WhiteSpace | Comment | ';' | '}'
lookahead1W(17); // %OTHER | EOF | Identifier | WhiteSpace | Comment | ';' | '}'
if (l1 != 38 && l1 >= 0 && followsLineTerminator()) // ';'
{
l1 = 38; // ';'
Expand All @@ -4900,15 +4902,15 @@ public class EcmaScript
{
consumeT(4); // Identifier
}
lookahead1W(15); // END | EOF | WhiteSpace | Comment | ';' | '}'
lookahead1W(15); // %OTHER | EOF | WhiteSpace | Comment | ';' | '}'
try_Semicolon();
}

private void parse_BreakStatement()
{
eventHandler.startNonterminal("BreakStatement", e0);
consume(57); // 'break'
lookahead1W(17); // END | EOF | Identifier | WhiteSpace | Comment | ';' | '}'
lookahead1W(17); // %OTHER | EOF | Identifier | WhiteSpace | Comment | ';' | '}'
if (l1 != 38 && l1 >= 0 && followsLineTerminator()) // ';'
{
l1 = 38; // ';'
Expand All @@ -4919,7 +4921,7 @@ public class EcmaScript
{
consume(4); // Identifier
}
lookahead1W(15); // END | EOF | WhiteSpace | Comment | ';' | '}'
lookahead1W(15); // %OTHER | EOF | WhiteSpace | Comment | ';' | '}'
whitespace();
parse_Semicolon();
eventHandler.endNonterminal("BreakStatement", e0);
Expand All @@ -4928,7 +4930,7 @@ public class EcmaScript
private void try_BreakStatement()
{
consumeT(57); // 'break'
lookahead1W(17); // END | EOF | Identifier | WhiteSpace | Comment | ';' | '}'
lookahead1W(17); // %OTHER | EOF | Identifier | WhiteSpace | Comment | ';' | '}'
if (l1 != 38 && l1 >= 0 && followsLineTerminator()) // ';'
{
l1 = 38; // ';'
Expand All @@ -4939,15 +4941,15 @@ public class EcmaScript
{
consumeT(4); // Identifier
}
lookahead1W(15); // END | EOF | WhiteSpace | Comment | ';' | '}'
lookahead1W(15); // %OTHER | EOF | WhiteSpace | Comment | ';' | '}'
try_Semicolon();
}

private void parse_ReturnStatement()
{
eventHandler.startNonterminal("ReturnStatement", e0);
consume(74); // 'return'
lookahead1W(26); // END | EOF | Identifier | NullLiteral | BooleanLiteral | StringLiteral |
lookahead1W(26); // %OTHER | EOF | Identifier | NullLiteral | BooleanLiteral | StringLiteral |
// RegularExpressionLiteral | DecimalLiteral | HexIntegerLiteral |
// OctalIntegerLiteral | WhiteSpace | Comment | '!' | '(' | '+' | '++' | '-' |
// '--' | ';' | '[' | 'delete' | 'function' | 'new' | 'this' | 'typeof' | 'void' |
Expand All @@ -4958,7 +4960,7 @@ public class EcmaScript
e1 = b1;
end = e1;
}
if (l1 != 1 // END
if (l1 != 1 // %OTHER
&& l1 != 3 // EOF
&& l1 != 38 // ';'
&& l1 != 89) // '}'
Expand All @@ -4974,7 +4976,7 @@ public class EcmaScript
private void try_ReturnStatement()
{
consumeT(74); // 'return'
lookahead1W(26); // END | EOF | Identifier | NullLiteral | BooleanLiteral | StringLiteral |
lookahead1W(26); // %OTHER | EOF | Identifier | NullLiteral | BooleanLiteral | StringLiteral |
// RegularExpressionLiteral | DecimalLiteral | HexIntegerLiteral |
// OctalIntegerLiteral | WhiteSpace | Comment | '!' | '(' | '+' | '++' | '-' |
// '--' | ';' | '[' | 'delete' | 'function' | 'new' | 'this' | 'typeof' | 'void' |
Expand All @@ -4985,7 +4987,7 @@ public class EcmaScript
e1 = b1;
end = e1;
}
if (l1 != 1 // END
if (l1 != 1 // %OTHER
&& l1 != 3 // EOF
&& l1 != 38 // ';'
&& l1 != 89) // '}'
Expand Down Expand Up @@ -5426,7 +5428,7 @@ public class EcmaScript
{
eventHandler.startNonterminal("DebuggerStatement", e0);
consume(61); // 'debugger'
lookahead1W(15); // END | EOF | WhiteSpace | Comment | ';' | '}'
lookahead1W(15); // %OTHER | EOF | WhiteSpace | Comment | ';' | '}'
whitespace();
parse_Semicolon();
eventHandler.endNonterminal("DebuggerStatement", e0);
Expand All @@ -5435,7 +5437,7 @@ public class EcmaScript
private void try_DebuggerStatement()
{
consumeT(61); // 'debugger'
lookahead1W(15); // END | EOF | WhiteSpace | Comment | ';' | '}'
lookahead1W(15); // %OTHER | EOF | WhiteSpace | Comment | ';' | '}'
try_Semicolon();
}

Expand Down Expand Up @@ -6348,8 +6350,8 @@ public class EcmaScript

private static final String[] TOKEN =
{
"(0)",
"END",
"%ERROR",
"%OTHER",
"Shebang",
"EOF",
"Identifier",
Expand Down
Loading

0 comments on commit 23e1942

Please sign in to comment.