Browse Source

Log some suppressed error messages

kindlich 4 years ago
parent
commit
6d5f6599ac
No known key found for this signature in database

+ 18
- 4
Parser/src/main/java/org/openzen/zenscript/parser/ParsedFile.java View File

32
 import org.openzen.zenscript.codemodel.statement.Statement;
32
 import org.openzen.zenscript.codemodel.statement.Statement;
33
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
33
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
34
 import org.openzen.zenscript.codemodel.type.ISymbol;
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
 import org.openzen.zenscript.parser.logger.*;
36
 import org.openzen.zenscript.parser.logger.*;
38
 import org.openzen.zenscript.parser.statements.ParsedStatement;
37
 import org.openzen.zenscript.parser.statements.ParsedStatement;
39
 
38
 
60
 			ModuleSpace registry,
59
 			ModuleSpace registry,
61
 			FunctionParameter[] parameters,
60
 			FunctionParameter[] parameters,
62
 			ParserLogger logger) {
61
 			ParserLogger logger) {
62
+	    boolean failed = false;
63
 		// We are considering all these files to be in the same package, so make
63
 		// We are considering all these files to be in the same package, so make
64
 		// a single PackageDefinition instance. If these files were in multiple
64
 		// a single PackageDefinition instance. If these files were in multiple
65
 		// packages, we'd need an instance for every package.
65
 		// packages, we'd need an instance for every package.
76
 		definitions.registerExpansionsTo(expansions);
76
 		definitions.registerExpansionsTo(expansions);
77
 		
77
 		
78
 		Map<String, ISymbol> globals = registry.collectGlobals();
78
 		Map<String, ISymbol> globals = registry.collectGlobals();
79
-		boolean failed = false;
80
 		
79
 		
81
 		ModuleTypeResolutionContext moduleContext = new ModuleTypeResolutionContext(
80
 		ModuleTypeResolutionContext moduleContext = new ModuleTypeResolutionContext(
82
 				registry.registry,
81
 				registry.registry,
99
 			// It doesn't yet compile the method contents.
98
 			// It doesn't yet compile the method contents.
100
 			file.compileTypes(moduleContext, rootPackage, pkg, importErrors);
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
 		if (failed)
111
 		if (failed)
104
 			return new SemanticModule(pkg.module, dependencies, parameters, SemanticModule.State.INVALID, rootPackage, pkg.getPackage(), definitions, Collections.emptyList(), registry.registry, expansions, registry.getAnnotations(), registry.getStorageTypes(), logger);
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
 			} else {
210
 			} else {
203
 				ParsedDefinition definition = ParsedDefinition.parse(compilingPackage, position, modifiers, annotations, tokens, null);
211
 				ParsedDefinition definition = ParsedDefinition.parse(compilingPackage, position, modifiers, annotations, tokens, null);
204
 				if (definition == null) {
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
 				} else {
220
 				} else {
207
 					result.definitions.add(definition);
221
 					result.definitions.add(definition);
208
 				}
222
 				}

+ 6
- 1
Parser/src/main/java/org/openzen/zenscript/parser/logger/ParserLogger.java View File

1
 package org.openzen.zenscript.parser.logger;
1
 package org.openzen.zenscript.parser.logger;
2
 
2
 
3
 import org.openzen.zencode.shared.logging.*;
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
+}

Loading…
Cancel
Save