Skip to content

Commit

Permalink
feat: create comment luau nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
R-unic committed Jan 6, 2025
1 parent c6bcd41 commit 1e15b4f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
7 changes: 4 additions & 3 deletions RobloxCS.Luau/AST/AST.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ public AST(List<Statement> statements)

public override void Render(LuauWriter luau)
{
luau.WriteLine("-- Compiled with roblox-cs v2.0.0");
new SingleLineComment("Compiled with roblox-cs v2.0.0").Render(luau);
luau.WriteLine();
luau.WriteLine();

foreach (var statement in Statements)
{
statement.Render(luau);
}

luau.WriteReturn();
}
}
Expand Down
6 changes: 6 additions & 0 deletions RobloxCS.Luau/AST/Comment.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace RobloxCS.Luau;

public abstract class Comment(string contents) : Node
{
public string Contents { get; } = contents;
}
11 changes: 11 additions & 0 deletions RobloxCS.Luau/AST/MultiLineComment.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace RobloxCS.Luau;

public class MultiLineComment(string contents) : Comment(contents)
{
public override void Render(LuauWriter luau)
{
luau.Write("--[[");
luau.Write(Contents);
luau.Write("]]");
}
}
10 changes: 10 additions & 0 deletions RobloxCS.Luau/AST/SingleLineComment.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace RobloxCS.Luau;

public class SingleLineComment(string contents) : Comment(contents)
{
public override void Render(LuauWriter luau)
{
luau.Write("-- ");
luau.Write(Contents);
}
}

0 comments on commit 1e15b4f

Please sign in to comment.