Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quoter #470

Draft
wants to merge 28 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
ac85bc4
Quoter skeleton
thinker227 Sep 3, 2024
f7c98e3
Implement quoting syntax tokens
thinker227 Sep 4, 2024
6bdf066
Add NotSupportedException for quoting syntax trivia
thinker227 Sep 4, 2024
87a3f47
Implement quoting syntax lists
thinker227 Sep 4, 2024
8959cd9
Add Float and Character methods to SyntaxFactory
thinker227 Sep 4, 2024
8961f1d
Add CreateInterleaved utility for SeparatedSyntaxList
thinker227 Sep 4, 2024
a13dd3d
Implement quoting separated syntax lists
thinker227 Sep 4, 2024
02ac879
Add QuoteList, QuoteTokenKind, and QuoteFloat
thinker227 Sep 4, 2024
d180c9c
Fix string escape issues
thinker227 Sep 4, 2024
7c07f5f
Make quoting a syntax list use SyntaxList method
thinker227 Sep 4, 2024
6bd7495
Use red tree instead of green tree
thinker227 Sep 4, 2024
bb095f8
Add type arguments
thinker227 Sep 4, 2024
9687afa
Little conundrum
thinker227 Sep 4, 2024
865dab8
Fix type issue with SeparatedSyntaxList in syntax factory
thinker227 Sep 5, 2024
5b22347
Merge branch 'main' into quoter
thinker227 Sep 10, 2024
f96fd5a
Vestigial stuff from merge
thinker227 Sep 10, 2024
8fc4aa9
Rewrite quoter sg
thinker227 Sep 10, 2024
4a42f4d
Fix some additional stuff
thinker227 Sep 10, 2024
a91bfc0
Update SyntaxToken quoting
thinker227 Sep 10, 2024
45b4635
Add C# output for quoter
thinker227 Sep 10, 2024
78b8267
Update indentation size
thinker227 Sep 10, 2024
785661d
Add quote command to dev host CLI
thinker227 Sep 10, 2024
1cb4faf
Merge branch 'main' into quoter
thinker227 Sep 11, 2024
cde4f2e
Add QuoteCharacter
thinker227 Sep 12, 2024
9a4778f
Fix some stuff for identifiers and literals
thinker227 Sep 12, 2024
3bdcb0f
Add CLI enums
thinker227 Sep 12, 2024
ca796d9
Add a couple simplification rules
thinker227 Sep 12, 2024
7f84576
Fix QuoteTokenKind not appending TokenKind.
thinker227 Sep 12, 2024
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
Prev Previous commit
Next Next commit
Implement quoting separated syntax lists
thinker227 committed Sep 4, 2024
commit a13dd3defa6bf0e57a5d4b1195bcb02c265cb401
10 changes: 6 additions & 4 deletions src/Draco.Compiler/Api/Syntax/Quoting/SyntaxQuoter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using System.Collections.Immutable;
using System.Linq;
using Draco.Compiler.Internal.Syntax;

namespace Draco.Compiler.Api.Syntax.Quoting;
@@ -131,9 +133,9 @@ public override QuoteExpression VisitSyntaxTrivia(Internal.Syntax.SyntaxTrivia n
public override QuoteExpression VisitSyntaxList<TNode>(Internal.Syntax.SyntaxList<TNode> node) =>
new QuoteList(node.Select(n => n.Accept(this)).ToImmutableArray());

public override QuoteExpression VisitSeparatedSyntaxList<TNode>(Internal.Syntax.SeparatedSyntaxList<TNode> node)
{
throw new NotImplementedException();
}
public override QuoteExpression VisitSeparatedSyntaxList<TNode>(Internal.Syntax.SeparatedSyntaxList<TNode> node) =>
new QuoteFunctionCall("SeparatedSyntaxList", [
new QuoteList(node.Separators.Select(x => x.Accept(this)).ToImmutableArray()),
new QuoteList(node.Values.Select(x => x.Accept(this)).ToImmutableArray())]);
}
}
8 changes: 8 additions & 0 deletions src/Draco.Compiler/Api/Syntax/SyntaxFactory.cs
Original file line number Diff line number Diff line change
@@ -84,6 +84,14 @@ public static SyntaxList<TNode> SyntaxList<TNode>(IEnumerable<TNode> elements)
public static SyntaxList<TNode> SyntaxList<TNode>(params TNode[] elements)
where TNode : SyntaxNode => SyntaxList(elements.AsEnumerable());

public static SeparatedSyntaxList<TNode> SeparatedSyntaxList<TNode>(IEnumerable<SyntaxToken> separators, IEnumerable<TNode> elements)
where TNode : SyntaxNode => new(
tree: null!,
parent: null,
fullPosition: 0,
green: Internal.Syntax.SeparatedSyntaxList.CreateInterleaved(
separators.Select(x => x.Green),
elements.Select(x => x.Green)));
public static SeparatedSyntaxList<TNode> SeparatedSyntaxList<TNode>(SyntaxToken separator, IEnumerable<TNode> elements)
where TNode : SyntaxNode => new(
tree: null!,