rename
This commit is contained in:
10
src/syntax/Parsing/Definitions/DefinitionNode.cs
Normal file
10
src/syntax/Parsing/Definitions/DefinitionNode.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using Nub.Lang.Common;
|
||||
using Nub.Lang.Syntax.Tokenization;
|
||||
|
||||
namespace Nub.Lang.Syntax.Parsing.Definitions;
|
||||
|
||||
public abstract class DefinitionNode(IReadOnlyList<Token> tokens, Optional<string> documentation, string @namespace) : Node(tokens)
|
||||
{
|
||||
public Optional<string> Documentation { get; } = documentation;
|
||||
public string Namespace { get; set; } = @namespace;
|
||||
}
|
||||
44
src/syntax/Parsing/Definitions/FuncDefinitionNode.cs
Normal file
44
src/syntax/Parsing/Definitions/FuncDefinitionNode.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using Nub.Lang.Common;
|
||||
using Nub.Lang.Syntax.Parsing.Statements;
|
||||
using Nub.Lang.Syntax.Tokenization;
|
||||
using Nub.Lang.Syntax.Typing;
|
||||
|
||||
namespace Nub.Lang.Syntax.Parsing.Definitions;
|
||||
|
||||
public class FuncParameter(string name, NubType type)
|
||||
{
|
||||
public string Name { get; } = name;
|
||||
public NubType Type { get; } = type;
|
||||
|
||||
public override string ToString() => $"{Name}: {Type}";
|
||||
}
|
||||
|
||||
public interface IFuncSignature
|
||||
{
|
||||
public string Name { get; }
|
||||
public List<FuncParameter> Parameters { get; }
|
||||
public NubType ReturnType { get; }
|
||||
|
||||
public string ToString() => $"{Name}({string.Join(", ", Parameters.Select(p => p.ToString()))}){": " + ReturnType}";
|
||||
}
|
||||
|
||||
public class LocalFuncDefinitionNode(IReadOnlyList<Token> tokens, Optional<string> documentation, string @namespace, string name, List<FuncParameter> parameters, BlockNode body, NubType returnType, bool exported) : DefinitionNode(tokens, documentation, @namespace), IFuncSignature
|
||||
{
|
||||
public string Name { get; } = name;
|
||||
public List<FuncParameter> Parameters { get; } = parameters;
|
||||
public BlockNode Body { get; } = body;
|
||||
public NubType ReturnType { get; } = returnType;
|
||||
public bool Exported { get; } = exported;
|
||||
|
||||
public override string ToString() => $"{Name}({string.Join(", ", Parameters.Select(p => p.ToString()))}){": " + ReturnType}";
|
||||
}
|
||||
|
||||
public class ExternFuncDefinitionNode(IReadOnlyList<Token> tokens, Optional<string> documentation, string @namespace, string name, string callName, List<FuncParameter> parameters, NubType returnType) : DefinitionNode(tokens, documentation, @namespace), IFuncSignature
|
||||
{
|
||||
public string Name { get; } = name;
|
||||
public string CallName { get; } = callName;
|
||||
public List<FuncParameter> Parameters { get; } = parameters;
|
||||
public NubType ReturnType { get; } = returnType;
|
||||
|
||||
public override string ToString() => $"{Name}({string.Join(", ", Parameters.Select(p => p.ToString()))}){": " + ReturnType}";
|
||||
}
|
||||
19
src/syntax/Parsing/Definitions/StructDefinitionNode.cs
Normal file
19
src/syntax/Parsing/Definitions/StructDefinitionNode.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using Nub.Lang.Common;
|
||||
using Nub.Lang.Syntax.Parsing.Expressions;
|
||||
using Nub.Lang.Syntax.Tokenization;
|
||||
using Nub.Lang.Syntax.Typing;
|
||||
|
||||
namespace Nub.Lang.Syntax.Parsing.Definitions;
|
||||
|
||||
public class StructField(string name, NubType type, Optional<ExpressionNode> value)
|
||||
{
|
||||
public string Name { get; } = name;
|
||||
public NubType Type { get; } = type;
|
||||
public Optional<ExpressionNode> Value { get; } = value;
|
||||
}
|
||||
|
||||
public class StructDefinitionNode(IReadOnlyList<Token> tokens, Optional<string> documentation, string @namespace, string name, List<StructField> fields) : DefinitionNode(tokens, documentation, @namespace)
|
||||
{
|
||||
public string Name { get; } = name;
|
||||
public List<StructField> Fields { get; } = fields;
|
||||
}
|
||||
Reference in New Issue
Block a user