Add translator source generator
This commit is contained in:
@@ -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);
|
||||
Reference in New Issue
Block a user