Add translator source generator

This commit is contained in:
2025-05-15 21:03:35 +02:00
parent a25cbd6dde
commit 871f46b996
11 changed files with 686 additions and 127 deletions

View File

@@ -1,9 +1,63 @@
// See https://aka.ms/new-console-template for more information
using System.Text;
using PoyoLang.Dictionary;
Console.OutputEncoding = System.Text.Encoding.UTF8;
var dictionary = new Dictionary<string, string>();
var text = "Lorem ipsum dolor sit amet";
var output = new StringBuilder(text.Length);
var span = text.AsSpan();
NextLetter(ref span, output);
Console.Write(output.ToString());
void NextLetter(ref ReadOnlySpan<char> text, StringBuilder output)
{
if (text.Length > 0)
{
var isCaps = char.IsUpper(text[0]);
switch (text[0])
{
case 'a' or 'A':
if (text.Length > 1)
{
switch (text[1])
{
case 'm':
text = text[2..];
output.Append(isCaps ? "Payo" : "payo");
return;
}
}
text = text[1..];
output.Append(isCaps ? "Piyo" : "piyo");
return;
case 'b' or 'B':
text = text[1..];
output.Append(isCaps ? "Pïyo" : "pïyo");
return;
}
text = text[1..];
output.Append(text[0]);
}
}
Console.WriteLine(string.Join(Environment.NewLine, Alphabet.BaseAlphabet));
Console.WriteLine(Alphabet.BaseAlphabet.Length);