|
46 | 46 | import java.nio.file.Paths;
|
47 | 47 | import java.util.EnumSet;
|
48 | 48 |
|
49 |
| -import com.oracle.graal.python.pegparser.tokenizer.SourceRange; |
50 | 49 | import org.junit.Assert;
|
51 | 50 | import org.junit.Rule;
|
52 | 51 | import org.junit.Test;
|
|
55 | 54 | import com.oracle.graal.python.compiler.CodeUnit;
|
56 | 55 | import com.oracle.graal.python.compiler.CompilationUnit;
|
57 | 56 | import com.oracle.graal.python.compiler.Compiler;
|
| 57 | +import com.oracle.graal.python.pegparser.ErrorCallback; |
58 | 58 | import com.oracle.graal.python.pegparser.FExprParser;
|
59 | 59 | import com.oracle.graal.python.pegparser.InputType;
|
60 | 60 | import com.oracle.graal.python.pegparser.NodeFactory;
|
|
63 | 63 | import com.oracle.graal.python.pegparser.ParserTokenizer;
|
64 | 64 | import com.oracle.graal.python.pegparser.sst.ExprTy;
|
65 | 65 | import com.oracle.graal.python.pegparser.sst.ModTy;
|
| 66 | +import com.oracle.graal.python.pegparser.tokenizer.SourceRange; |
66 | 67 | import com.oracle.graal.python.test.PythonTests;
|
67 | 68 |
|
68 | 69 | public class CompilerTests extends PythonTests {
|
@@ -727,18 +728,21 @@ private void doTest(String src) {
|
727 | 728 | }
|
728 | 729 |
|
729 | 730 | private void doTest(String src, InputType type) {
|
| 731 | + ErrorCallback errorCallback = (errorType, sourceRange, message) -> { |
| 732 | + throw new AssertionError("Unexpected syntax error: " + message); |
| 733 | + }; |
730 | 734 | ParserTokenizer tokenizer = new ParserTokenizer(src);
|
731 | 735 | NodeFactory factory = new NodeFactoryImp();
|
732 | 736 | FExprParser fexpParser = new FExprParser() {
|
733 | 737 | @Override
|
734 | 738 | public ExprTy parse(String code, SourceRange sourceRange) {
|
735 | 739 | ParserTokenizer tok = new ParserTokenizer(code);
|
736 |
| - return new Parser(tok, factory, this).fstring_rule(); |
| 740 | + return new Parser(tok, factory, this, errorCallback).fstring_rule(); |
737 | 741 | }
|
738 | 742 | };
|
739 |
| - Parser parser = new Parser(tokenizer, factory, fexpParser); |
| 743 | + Parser parser = new Parser(tokenizer, factory, fexpParser, errorCallback); |
740 | 744 | ModTy result = (ModTy) parser.parse(type);
|
741 |
| - Compiler compiler = new Compiler(); |
| 745 | + Compiler compiler = new Compiler(errorCallback); |
742 | 746 | CompilationUnit cu = compiler.compile(result, EnumSet.noneOf(Compiler.Flags.class), 2);
|
743 | 747 | CodeUnit co = cu.assemble(0);
|
744 | 748 | checkCodeUnit(co);
|
|
0 commit comments