Add translator to poyo
This commit is contained in:
@@ -1,63 +1,14 @@
|
||||
// See https://aka.ms/new-console-template for more information
|
||||
|
||||
using System.Text;
|
||||
using PoyoLang.Dictionary;
|
||||
using PoyoLang.Translator;
|
||||
|
||||
var dictionary = new Dictionary<string, string>();
|
||||
Console.OutputEncoding = Encoding.UTF8;
|
||||
|
||||
var text = "Lorem ipsum dolor sit amet";
|
||||
var text = "Immutable abstract representation of a span of text. For example, in an error diagnostic that reports a location, it could come from a parsed string, text from a tool editor buffer, etc.";
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
||||
var translator = new PoyoLangTranslator();
|
||||
|
||||
var translated = translator.TranslateToPoyo(text);
|
||||
|
||||
Console.WriteLine(translated);
|
||||
Reference in New Issue
Block a user