parent
638284976a
commit
8dfd3f001f
|
@ -9,8 +9,15 @@ import tlang.compiler.lexer.core;
|
||||||
import core.stdc.stdlib;
|
import core.stdc.stdlib;
|
||||||
import misc.exceptions : TError;
|
import misc.exceptions : TError;
|
||||||
import tlang.compiler.parsing.exceptions;
|
import tlang.compiler.parsing.exceptions;
|
||||||
|
import tlang.compiler.reporting : LineInfo;Par
|
||||||
|
|
||||||
// TODO: Technically we could make a core parser etc
|
/**
|
||||||
|
* Provided with a lexer this
|
||||||
|
* can parse the tokens into
|
||||||
|
* an in-memory AST structure
|
||||||
|
*
|
||||||
|
* Authors: Tristan Brice Velloza Kildaire (deavmi)
|
||||||
|
*/
|
||||||
public final class Parser
|
public final class Parser
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -18,6 +25,22 @@ public final class Parser
|
||||||
*/
|
*/
|
||||||
private LexerInterface lexer;
|
private LexerInterface lexer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the `LineInfo` of
|
||||||
|
* the lexer's current token.
|
||||||
|
*
|
||||||
|
* This is useful when you want
|
||||||
|
* to associate a line with
|
||||||
|
* an AST node right before
|
||||||
|
* returning.
|
||||||
|
*
|
||||||
|
* Returns: the `LineInfo`
|
||||||
|
*/
|
||||||
|
private LineInfo getCurrentLineInfo()
|
||||||
|
{
|
||||||
|
return this.lexer.getCurrentToken().getLineInfo();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Crashes the program if the given token is not a symbol
|
* Crashes the program if the given token is not a symbol
|
||||||
* the same as the givne expected one
|
* the same as the givne expected one
|
||||||
|
|
Loading…
Reference in New Issue