tlang/source/tlang/compiler/parsing/exceptions.d

35 lines
891 B
D
Raw Normal View History

2021-06-08 09:37:38 +01:00
module compiler.parsing.exceptions;
2021-06-08 09:45:14 +01:00
import compiler.parsing.core;
import misc.exceptions;
import compiler.symbols.check;
import compiler.symbols.data;
import compiler.lexer.core : Token;
import std.conv : to;
2021-06-08 09:45:14 +01:00
2021-06-08 09:37:38 +01:00
public class ParserException : TError
{
private Parser parser;
2021-06-08 09:37:38 +01:00
this(Parser parser, string message)
{
super(message);
this.parser = parser;
2021-06-08 09:37:38 +01:00
}
}
2021-06-08 09:37:43 +01:00
public final class SyntaxError : ParserException
{
private SymbolType expected;
private SymbolType provided;
private Token providedToken;
2021-06-08 09:37:43 +01:00
this(Parser parser, SymbolType expected, Token providedToken)
2021-06-08 09:37:43 +01:00
{
this.expected = expected;
App - Added newline to release info print - Fixed module docstring Commands - Added new command-line options: `syntaxcheck`, `typecheck` - Added todo to `help` command - Re-ordered commands for order of appearance in help text Compiler - Added docstring to `beginCompilation(string[])` function Mapper - Added debug print of the Container being used for the symbol lookup CodeEmitter - Re-worked CodeEmitter class to use a single so-called "selected queue" - Added methods to move back and forth between said "selected queue", get the length, etc. - Remove old queue-specific methods DGen - Use the new CodeEmitter "selected-queue" functionality - Emit function definitions now supported Exceptions - Added this keyword Check - Added support for SymbolTYpe.OCURLY and SymbolType.CCURLY to `getCharacter(SymbolType)` Data - Added a `hasParams()` method to the Function entity type TypeChecker - Added support for emitting function definitions (required DNode.poes = [] (cleaning), codeQueue cleaning etc.) - Added `getInitQueue()` method to make a copy of the current "scratchpad" `codeQueue` - Build up a copy of the global queue now (make a copy similiar to what we did for `getInitQueue()` but inline) - Added a debug print Dependency - Added a FIXME note for issue #46 - Added a TODO relating to `static DNode[] poes` Test cases - Added test case `simple_function_decls.t` to test function definition code emit - Updated test case `simple_variables.t` to note that the T code generates invalid C code README - Build instructions now generate coverage files (`.lst`s) - Updated link to documentation
2022-12-14 17:49:08 +00:00
this.provided = getSymbolType(providedToken);
this.providedToken = providedToken;
super(parser, "Syntax error: Expected "~to!(string)(expected)~" but got "~to!(string)(provided)~", see "~providedToken.toString());
2021-06-08 09:37:43 +01:00
}
}