-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
84 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using System.Text; | ||
|
||
namespace Linguini.Syntax.Ast | ||
{ | ||
public static class AstDebugHelper | ||
{ | ||
public static string Debug(this AstMessage message) | ||
{ | ||
var stringBuilder = new StringBuilder(); | ||
if (message.Value != null) | ||
{ | ||
foreach (var patternElement in message.Value.Elements) | ||
{ | ||
switch (patternElement) | ||
{ | ||
case TextLiteral textLiteral: | ||
stringBuilder.Append(textLiteral.Value); | ||
break; | ||
case Placeable placeable: | ||
Debug(placeable, stringBuilder); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
return stringBuilder.ToString(); | ||
} | ||
|
||
private static void Debug(Placeable placeable, StringBuilder stringBuilder) | ||
{ | ||
switch (placeable.Expression) | ||
{ | ||
case SelectExpression selectExpression: | ||
Debug(selectExpression, stringBuilder); | ||
break; | ||
case IInlineExpression inlineExpression: | ||
Debug(inlineExpression, stringBuilder); | ||
break; | ||
} | ||
} | ||
|
||
private static void Debug(IInlineExpression inlineExpression, StringBuilder stringBuilder) | ||
{ | ||
throw new System.NotImplementedException(); | ||
} | ||
|
||
private static void Debug(SelectExpression selectExpression, StringBuilder stringBuilder) | ||
{ | ||
throw new System.NotImplementedException(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters