Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions SudoScript.Core/Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,22 +119,24 @@ private static List<ParameterNode> ParseParameters(TokenStream stream)
List<ParameterNode> paramChildren = new List<ParameterNode>();

// While leftBrace is not read, it will keep reading parameters.
while (stream.Peek(true ,out Token? endToken) && endToken.Type != TokenType.LeftBrace)
while (stream.Peek(true ,out Token? endToken) && endToken.Type != TokenType.LeftBrace)
{
if (!stream.Expect(TokenType.Space, out Token _))
if (!stream.Expect(TokenType.Space, out Token? _))
{
throw new Exception("Parameter are expected to be separated by space");
}

// Checks whether the parameter is an identifier or a cell and parses them acordingly
if (stream.Peek(true, out Token? leftParenthesis) && leftParenthesis.Type == TokenType.LeftParenthesis)
else
{
paramChildren.Add(ParseParameterCell(stream));
}
// Checks whether the parameter is an identifier or a cell and parses them acordingly
if (stream.Peek(true, out Token? leftParenthesis) && leftParenthesis.Type == TokenType.LeftParenthesis)
{
paramChildren.Add(ParseParameterCell(stream));
}

if (stream.Peek(true, out Token? identifier) && identifier.Type == TokenType.Identifier)
{
paramChildren.Add(ParseParameterIdentifier(stream));
if (stream.Peek(true, out Token? identifier) && identifier.Type == TokenType.Identifier)
{
paramChildren.Add(ParseParameterIdentifier(stream));
}
}
}

Expand Down
4 changes: 1 addition & 3 deletions SudoScript.Core/Tokenizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ public sealed class TokenStream : IDisposable

private char? _carry;

private readonly string _src;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure this was supposed to be used to exceptions. I would probably rather that we implement those exceptions than remove the property.


public TokenStream(TextReader reader)
{
_reader = reader;
Expand Down Expand Up @@ -256,7 +254,7 @@ private bool GetToken([NotNullWhen(true)] out Token? nextToken)
throw new ArgumentException($"Unrecognized character: {character} is not a recognised token");
}

nextToken = new Token(type, match, row, column, _src);
nextToken = new Token(type, match, row, column, "");

if (nextToken.Type == TokenType.BlockComment || nextToken.Type == TokenType.LineComment)
{
Expand Down