7
7
8
8
import com .adacore .liblkqllang .Liblkqllang ;
9
9
import com .adacore .lkql_jit .built_ins .values .LKQLNamespace ;
10
+ import com .adacore .lkql_jit .checker .utils .CheckerUtils ;
10
11
import com .adacore .lkql_jit .exception .LKQLRuntimeException ;
11
12
import com .adacore .lkql_jit .langkit_translator .passes .FramingPass ;
12
13
import com .adacore .lkql_jit .langkit_translator .passes .TranslationPass ;
17
18
import com .adacore .lkql_jit .runtime .GlobalScope ;
18
19
import com .adacore .lkql_jit .utils .Constants ;
19
20
import com .adacore .lkql_jit .utils .enums .DiagnosticOutputMode ;
21
+ import com .adacore .lkql_jit .utils .source_location .SourceSectionWrapper ;
20
22
import com .oracle .truffle .api .CallTarget ;
21
23
import com .oracle .truffle .api .Option ;
22
24
import com .oracle .truffle .api .TruffleLanguage ;
@@ -323,9 +325,6 @@ protected OptionDescriptors getOptionDescriptors() {
323
325
return new LKQLLanguageOptionDescriptors ();
324
326
}
325
327
326
- /**
327
- * @see com.oracle.truffle.api.TruffleLanguage#parse(ParsingRequest)
328
- */
329
328
@ Override
330
329
protected CallTarget parse (ParsingRequest request ) {
331
330
final Liblkqllang .AnalysisUnit unit ;
@@ -341,9 +340,22 @@ protected CallTarget parse(ParsingRequest request) {
341
340
}
342
341
343
342
// Verify the parsing result
344
- final Liblkqllang . Diagnostic [] diagnostics = unit .getDiagnostics ();
343
+ final var diagnostics = unit .getDiagnostics ();
345
344
if (diagnostics .length > 0 ) {
346
- throw LKQLRuntimeException .parsingException (diagnostics , request .getSource ());
345
+ var ctx = LKQLLanguage .getContext (null );
346
+
347
+ // Iterate over diagnostics
348
+ for (Liblkqllang .Diagnostic diagnostic : diagnostics ) {
349
+ ctx .getDiagnosticEmitter ()
350
+ .emitDiagnostic (
351
+ CheckerUtils .MessageKind .ERROR ,
352
+ diagnostic .message .toString (),
353
+ null ,
354
+ SourceSectionWrapper .create (
355
+ diagnostic .sourceLocationRange , request .getSource ()));
356
+ }
357
+ throw LKQLRuntimeException .fromMessage (
358
+ "Syntax errors in " + unit .getFileName (false ) + ": stopping interpreter" );
347
359
}
348
360
349
361
// Get the LKQL langkit AST
@@ -357,7 +369,10 @@ protected CallTarget parse(ParsingRequest request) {
357
369
// Print the Truffle AST if the JIT is in debug mode
358
370
if (getContext (result ).isVerbose ()) {
359
371
System .out .println (
360
- "=== Truffle AST <" + result .getLocation ().getFileName () + "> :\n " + result );
372
+ "=== Truffle AST <"
373
+ + result .getSourceSection ().getSource ().getPath ()
374
+ + "> :\n "
375
+ + result );
361
376
}
362
377
363
378
// Return the call target
0 commit comments