Skip to content

Commit

Permalink
Merge pull request #383 from Luthetus/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
Luthetus authored Dec 17, 2024
2 parents 167bf8a + b7ae97a commit e977845
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Source/Lib/Common/Keys/Models/Key.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Luthetus.Common.RazorLib.Keys.Models;
namespace Luthetus.Common.RazorLib.Keys.Models;

public record struct Key<T>(Guid Guid)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ public IExpressionNode AnyMergeToken(
return FunctionParametersListingMergeToken((FunctionParametersListingNode)expressionPrimary, token, compilationUnit, ref parserModel);
case SyntaxKind.FunctionArgumentsListingNode:
return FunctionArgumentsListingMergeToken((FunctionArgumentsListingNode)expressionPrimary, token, compilationUnit, ref parserModel);
case SyntaxKind.ReturnStatementNode:
return ReturnStatementMergeToken((ReturnStatementNode)expressionPrimary, token, compilationUnit, ref parserModel);
case SyntaxKind.BadExpressionNode:
return BadMergeToken((BadExpressionNode)expressionPrimary, token, compilationUnit, ref parserModel);
default:
Expand Down Expand Up @@ -126,6 +128,8 @@ public IExpressionNode AnyMergeExpression(
return FunctionParametersListingMergeExpression((FunctionParametersListingNode)expressionPrimary, expressionSecondary, compilationUnit, ref parserModel);
case SyntaxKind.FunctionArgumentsListingNode:
return FunctionArgumentsListingMergeExpression((FunctionArgumentsListingNode)expressionPrimary, expressionSecondary, compilationUnit, ref parserModel);
case SyntaxKind.ReturnStatementNode:
return ReturnStatementMergeExpression((ReturnStatementNode)expressionPrimary, expressionSecondary, compilationUnit, ref parserModel);
case SyntaxKind.BadExpressionNode:
return BadMergeExpression((BadExpressionNode)expressionPrimary, expressionSecondary, compilationUnit, ref parserModel);
default:
Expand Down Expand Up @@ -818,7 +822,6 @@ public IExpressionNode EmptyMergeToken(
BindStringVerbatimExpression((AtToken)token, compilationUnit);
return emptyExpressionNode;
case SyntaxKind.OutTokenKeyword:

if (UtilityApi.IsConvertibleToIdentifierToken(parserModel.TokenWalker.Current.SyntaxKind))
{
// Parse the variable reference / variable declaration
Expand All @@ -829,16 +832,21 @@ public IExpressionNode EmptyMergeToken(
case SyntaxKind.InTokenKeyword:
case SyntaxKind.RefTokenKeyword:
case SyntaxKind.ParamsTokenKeyword:
case SyntaxKind.ThisTokenKeyword:
return emptyExpressionNode;
case SyntaxKind.OpenAngleBracketToken:
var genericParametersListingNode = new GenericParametersListingNode(
(OpenAngleBracketToken)token,
new List<GenericParameterEntryNode>(),
closeAngleBracketToken: default);

parserModel.ExpressionList.Add((SyntaxKind.CloseAngleBracketToken, genericParametersListingNode));
parserModel.ExpressionList.Add((SyntaxKind.CloseAngleBracketToken, genericParametersListingNode));
parserModel.ExpressionList.Add((SyntaxKind.CommaToken, genericParametersListingNode));
return EmptyExpressionNode.Empty;
case SyntaxKind.ReturnTokenKeyword:
var returnStatementNode = new ReturnStatementNode((KeywordToken)token, EmptyExpressionNode.Empty);
parserModel.ExpressionList.Add((SyntaxKind.EndOfFileToken, returnStatementNode));
return EmptyExpressionNode.Empty;
default:
return new BadExpressionNode(CSharpFacts.Types.Void.ToTypeClause(), emptyExpressionNode, token);
}
Expand Down Expand Up @@ -1019,6 +1027,22 @@ public IExpressionNode FunctionArgumentsListingMergeExpression(
return functionArgumentsListingNode;
}

public IExpressionNode ReturnStatementMergeToken(
ReturnStatementNode returnStatementNode, ISyntaxToken token, CSharpCompilationUnit compilationUnit, ref CSharpParserModel parserModel)
{
switch (token.SyntaxKind)
{
default:
return new BadExpressionNode(CSharpFacts.Types.Void.ToTypeClause(), returnStatementNode, token);
}
}

public IExpressionNode ReturnStatementMergeExpression(
ReturnStatementNode returnStatementNode, IExpressionNode expressionSecondary, CSharpCompilationUnit compilationUnit, ref CSharpParserModel parserModel)
{
return new BadExpressionNode(CSharpFacts.Types.Void.ToTypeClause(), returnStatementNode, expressionSecondary);
}

public IExpressionNode LambdaMergeToken(
LambdaExpressionNode lambdaExpressionNode, ISyntaxToken token, CSharpCompilationUnit compilationUnit, ref CSharpParserModel parserModel)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,9 @@ public static void HandleStorageModifierTokenKeyword(CSharpCompilationUnit compi

compilationUnit.Binder.BindTypeDefinitionNode(typeDefinitionNode, compilationUnit);
compilationUnit.Binder.BindTypeIdentifier(identifierToken, compilationUnit);

parserModel.SyntaxStack.Push(typeDefinitionNode);
parserModel.StatementBuilder.ChildList.Add(typeDefinitionNode);
parserModel.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = typeDefinitionNode;
}

Expand Down Expand Up @@ -908,5 +910,6 @@ public static void HandleNamespaceTokenKeyword(CSharpCompilationUnit compilation
public static void HandleReturnTokenKeyword(CSharpCompilationUnit compilationUnit, ref CSharpParserModel parserModel)
{
parserModel.StatementBuilder.ChildList.Add((KeywordToken)parserModel.TokenWalker.Consume());
// var expressionNode = ParseOthers.ParseExpression(compilationUnit, ref parserModel);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ public static FunctionArgumentsListingNode HandleFunctionArguments(CSharpCompila
if (parserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.OutTokenKeyword ||
parserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.InTokenKeyword ||
parserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.RefTokenKeyword ||
parserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.ParamsTokenKeyword)
parserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.ParamsTokenKeyword ||
parserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.ThisTokenKeyword)
{
_ = parserModel.TokenWalker.Consume();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,12 @@ public static void ParseCloseBraceToken(CloseBraceToken closeBraceToken, CSharpC

public static void ParseOpenParenthesisToken(CSharpCompilationUnit compilationUnit, ref CSharpParserModel parserModel)
{
if (parserModel.SyntaxStack.TryPeek(out var syntax) && syntax.SyntaxKind == SyntaxKind.TypeDefinitionNode)
{
var typeDefinitionNode = (TypeDefinitionNode)parserModel.SyntaxStack.Pop();
var functionArgumentsListingNode = ParseFunctions.HandleFunctionArguments(compilationUnit, ref parserModel);
typeDefinitionNode.SetPrimaryConstructorFunctionArgumentsListingNode(functionArgumentsListingNode);
}
}

public static void ParseCloseParenthesisToken(
Expand Down
2 changes: 1 addition & 1 deletion Source/Lib/Ide/Ide.RazorLib/Luthetus.Ide.RazorLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Version>0.9.7.8</Version>
<Version>0.9.7.9</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,17 @@
Recent Changes:
<div>
<div>
<div>v <em class="luth_em">0.9.7.9 </em> (WIP_DATE)</div>
<ul>
<li>
Fix: 'this' keyword in function arguments listing.
</li>
<li>
Fix: primary constructor syntax.
</li>
</ul>
</div>
<div>
<div>v <em class="luth_em">0.9.7.8 </em> (2024-12-16)</div>
<ul>
<li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes;

public sealed class ReturnStatementNode : ISyntaxNode
public sealed class ReturnStatementNode : IExpressionNode
{
public ReturnStatementNode(KeywordToken keywordToken, IExpressionNode expressionNode)
{
Expand All @@ -17,6 +17,7 @@ public ReturnStatementNode(KeywordToken keywordToken, IExpressionNode expression

public KeywordToken KeywordToken { get; }
public IExpressionNode ExpressionNode { get; }
public TypeClauseNode ResultTypeClauseNode => ExpressionNode.ResultTypeClauseNode;

public bool IsFabricated { get; init; }
public SyntaxKind SyntaxKind => SyntaxKind.ReturnStatementNode;
Expand Down

0 comments on commit e977845

Please sign in to comment.