Pārlūkot izejas kodu

Log some suppressed error messages

kindlich 4 gadus atpakaļ
vecāks
revīzija
6d5f6599ac
Šim parakstam datu bāzē netika atrasta zināma atslēga

+ 18
- 4
Parser/src/main/java/org/openzen/zenscript/parser/ParsedFile.java Parādīt failu

@@ -32,8 +32,7 @@ import org.openzen.zenscript.codemodel.scope.StatementScope;
32 32
 import org.openzen.zenscript.codemodel.statement.Statement;
33 33
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
34 34
 import org.openzen.zenscript.codemodel.type.ISymbol;
35
-import org.openzen.zenscript.lexer.ParseException;
36
-import org.openzen.zenscript.lexer.ZSTokenParser;
35
+import org.openzen.zenscript.lexer.*;
37 36
 import org.openzen.zenscript.parser.logger.*;
38 37
 import org.openzen.zenscript.parser.statements.ParsedStatement;
39 38
 
@@ -60,6 +59,7 @@ public class ParsedFile {
60 59
 			ModuleSpace registry,
61 60
 			FunctionParameter[] parameters,
62 61
 			ParserLogger logger) {
62
+	    boolean failed = false;
63 63
 		// We are considering all these files to be in the same package, so make
64 64
 		// a single PackageDefinition instance. If these files were in multiple
65 65
 		// packages, we'd need an instance for every package.
@@ -76,7 +76,6 @@ public class ParsedFile {
76 76
 		definitions.registerExpansionsTo(expansions);
77 77
 		
78 78
 		Map<String, ISymbol> globals = registry.collectGlobals();
79
-		boolean failed = false;
80 79
 		
81 80
 		ModuleTypeResolutionContext moduleContext = new ModuleTypeResolutionContext(
82 81
 				registry.registry,
@@ -99,6 +98,15 @@ public class ParsedFile {
99 98
 			// It doesn't yet compile the method contents.
100 99
 			file.compileTypes(moduleContext, rootPackage, pkg, importErrors);
101 100
 		}
101
+        
102
+        for(ParsedFile file : files) {
103
+            if(file.hasErrors()) {
104
+                failed = true;
105
+                for(ParseException error : file.errors) {
106
+                    logger.logParseException(error);
107
+                }
108
+            }
109
+        }
102 110
 		
103 111
 		if (failed)
104 112
 			return new SemanticModule(pkg.module, dependencies, parameters, SemanticModule.State.INVALID, rootPackage, pkg.getPackage(), definitions, Collections.emptyList(), registry.registry, expansions, registry.getAnnotations(), registry.getStorageTypes(), logger);
@@ -202,7 +210,13 @@ public class ParsedFile {
202 210
 			} else {
203 211
 				ParsedDefinition definition = ParsedDefinition.parse(compilingPackage, position, modifiers, annotations, tokens, null);
204 212
 				if (definition == null) {
205
-					result.statements.add(ParsedStatement.parse(tokens, annotations));
213
+				    try {
214
+                        result.statements.add(ParsedStatement.parse(tokens, annotations));
215
+                    }catch (ParseException e) {
216
+				        tokens.logError(e);
217
+				        tokens.recoverUntilToken(ZSTokenType.T_SEMICOLON);
218
+				        tokens.next();
219
+                    }
206 220
 				} else {
207 221
 					result.definitions.add(definition);
208 222
 				}

+ 6
- 1
Parser/src/main/java/org/openzen/zenscript/parser/logger/ParserLogger.java Parādīt failu

@@ -1,5 +1,10 @@
1 1
 package org.openzen.zenscript.parser.logger;
2 2
 
3 3
 import org.openzen.zencode.shared.logging.*;
4
+import org.openzen.zenscript.lexer.*;
4 5
 
5
-public interface ParserLogger extends IZSLogger, CompileExceptionLogger {}
6
+public interface ParserLogger extends IZSLogger, CompileExceptionLogger {
7
+    default void logParseException(ParseException exception) {
8
+        throwingErr("Parser Exeption", exception);
9
+    }
10
+}

Notiek ielāde…
Atcelt
Saglabāt