Skip to content

Commit

Permalink
Parser
Browse files Browse the repository at this point in the history
- Implemented `tryParseExpression(ref Expression expression)`
  • Loading branch information
deavmi committed May 21, 2024
1 parent 43d9b09 commit 39772d8
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions source/tlang/compiler/parsing/core.d
Original file line number Diff line number Diff line change
Expand Up @@ -1567,6 +1567,31 @@ public final class Parser
return retExpression[0];
}

/**
* Attempts to parse an expression, however,
* if there is any error then this is simply
* returned as a boolean flag rather than
* the entire process crashing
*
* Params:
* expression = the found expression, in
* the case of no errors
* Returns: `true` if an expression parsed
* successfully, `false` otherwise
*/
private bool tryParseExpression(ref Expression expression)
{
try
{
expression = parseExpression();
return true;
}
catch(ParserException e)
{
return false;
}
}

// FIXME: This should STILL work pre-dot and post-dot fixeup
private string parseTypeNameOnly()
{
Expand Down Expand Up @@ -1609,6 +1634,9 @@ public final class Parser
Statement generated;


ulong entrancePos = lexer.getCursor();


/* TODO: Save type */
string type = parseTypeNameOnly();
DEBUG(format("tryParseName: %s", type));
Expand Down Expand Up @@ -1736,6 +1764,9 @@ public final class Parser
DEBUG("ParseTypedDec: SymbolType=" ~ to!(string)(symbolType));
if (symbolType == SymbolType.LBRACE)
{
// FIXME: Rewind to `entrancePos` here and then capture the name as an Expression


// Only continue is function definitions are allowed
if(allowFuncDef)
{
Expand Down

0 comments on commit 39772d8

Please sign in to comment.