...
This commit is contained in:
@@ -83,11 +83,6 @@ public sealed class Parser(List<Token> tokens)
|
||||
return new NodeExpressionIntLiteral(TokensFrom(startIndex), intLiteral);
|
||||
}
|
||||
|
||||
if (TryExpectFloatLiteral(out var floatLiteral))
|
||||
{
|
||||
return new NodeExpressionFloatLiteral(TokensFrom(startIndex), floatLiteral);
|
||||
}
|
||||
|
||||
if (TryExpectStringLiteral(out var stringLiteral))
|
||||
{
|
||||
return new NodeExpressionStringLiteral(TokensFrom(startIndex), stringLiteral);
|
||||
@@ -227,19 +222,6 @@ public sealed class Parser(List<Token> tokens)
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool TryExpectFloatLiteral([NotNullWhen(true)] out TokenFloatLiteral? floatLiteral)
|
||||
{
|
||||
if (Peek() is TokenFloatLiteral token)
|
||||
{
|
||||
Consume();
|
||||
floatLiteral = token;
|
||||
return true;
|
||||
}
|
||||
|
||||
floatLiteral = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool TryExpectStringLiteral([NotNullWhen(true)] out TokenStringLiteral? stringLiteral)
|
||||
{
|
||||
if (Peek() is TokenStringLiteral token)
|
||||
@@ -293,15 +275,15 @@ public abstract class NodeDefinition(List<Token> tokens) : Node(tokens);
|
||||
public sealed class NodeDefinitionFunc(List<Token> tokens, TokenIdent name, List<NodeDefinitionFunc.Param> parameters, NodeStatement body, NodeType returnType)
|
||||
: NodeDefinition(tokens)
|
||||
{
|
||||
public TokenIdent Name = name;
|
||||
public List<Param> Parameters = parameters;
|
||||
public NodeStatement Body = body;
|
||||
public NodeType ReturnType = returnType;
|
||||
public readonly TokenIdent Name = name;
|
||||
public readonly List<Param> Parameters = parameters;
|
||||
public readonly NodeStatement Body = body;
|
||||
public readonly NodeType ReturnType = returnType;
|
||||
|
||||
public sealed class Param(List<Token> tokens, TokenIdent name, NodeType type) : Node(tokens)
|
||||
{
|
||||
public TokenIdent Name = name;
|
||||
public NodeType Type = type;
|
||||
public readonly TokenIdent Name = name;
|
||||
public readonly NodeType Type = type;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -309,40 +291,35 @@ public abstract class NodeStatement(List<Token> tokens) : Node(tokens);
|
||||
|
||||
public sealed class NodeStatementBlock(List<Token> tokens, List<NodeStatement> statements) : NodeStatement(tokens)
|
||||
{
|
||||
public List<NodeStatement> Statements = statements;
|
||||
public readonly List<NodeStatement> Statements = statements;
|
||||
}
|
||||
|
||||
public sealed class NodeStatementFuncCall(List<Token> tokens, NodeExpression func, List<NodeExpression> parameters) : NodeStatement(tokens)
|
||||
{
|
||||
public NodeExpression Func = func;
|
||||
public List<NodeExpression> Parameters = parameters;
|
||||
public readonly NodeExpression Func = func;
|
||||
public readonly List<NodeExpression> Parameters = parameters;
|
||||
}
|
||||
|
||||
public abstract class NodeExpression(List<Token> tokens) : Node(tokens);
|
||||
|
||||
public sealed class NodeExpressionIntLiteral(List<Token> tokens, TokenIntLiteral value) : NodeExpression(tokens)
|
||||
{
|
||||
public TokenIntLiteral Value = value;
|
||||
}
|
||||
|
||||
public sealed class NodeExpressionFloatLiteral(List<Token> tokens, TokenFloatLiteral value) : NodeExpression(tokens)
|
||||
{
|
||||
public TokenFloatLiteral Value = value;
|
||||
public readonly TokenIntLiteral Value = value;
|
||||
}
|
||||
|
||||
public sealed class NodeExpressionStringLiteral(List<Token> tokens, TokenStringLiteral value) : NodeExpression(tokens)
|
||||
{
|
||||
public TokenStringLiteral Value = value;
|
||||
public readonly TokenStringLiteral Value = value;
|
||||
}
|
||||
|
||||
public sealed class NodeExpressionBoolLiteral(List<Token> tokens, TokenBoolLiteral value) : NodeExpression(tokens)
|
||||
{
|
||||
public TokenBoolLiteral Value = value;
|
||||
public readonly TokenBoolLiteral Value = value;
|
||||
}
|
||||
|
||||
public sealed class NodeExpressionIdent(List<Token> tokens, TokenIdent value) : NodeExpression(tokens)
|
||||
{
|
||||
public TokenIdent Value = value;
|
||||
public readonly TokenIdent Value = value;
|
||||
}
|
||||
|
||||
public abstract class NodeType(List<Token> tokens) : Node(tokens);
|
||||
@@ -351,27 +328,27 @@ public sealed class NubTypeVoid(List<Token> tokens) : NodeType(tokens);
|
||||
|
||||
public sealed class NodeTypeUInt(List<Token> tokens, int width) : NodeType(tokens)
|
||||
{
|
||||
public int Width = width;
|
||||
public readonly int Width = width;
|
||||
}
|
||||
|
||||
public sealed class NodeTypeSInt(List<Token> tokens, int width) : NodeType(tokens)
|
||||
{
|
||||
public int Width = width;
|
||||
public readonly int Width = width;
|
||||
}
|
||||
|
||||
public sealed class NodeTypeFloat(List<Token> tokens, int width) : NodeType(tokens)
|
||||
{
|
||||
public int Width = width;
|
||||
public readonly int Width = width;
|
||||
}
|
||||
|
||||
public sealed class NodeTypeString(List<Token> tokens) : NodeType(tokens);
|
||||
|
||||
public sealed class NodeTypeCustom(List<Token> tokens, TokenIdent name) : NodeType(tokens)
|
||||
{
|
||||
public TokenIdent Name = name;
|
||||
public readonly TokenIdent Name = name;
|
||||
}
|
||||
|
||||
public sealed class NodeTypePointer(List<Token> tokens, NodeType to) : NodeType(tokens)
|
||||
{
|
||||
public NodeType To = to;
|
||||
public readonly NodeType To = to;
|
||||
}
|
||||
Reference in New Issue
Block a user