Remove XML from UIXA parsing

This commit is contained in:
Yoshi Askharoun
2025-01-27 18:41:39 -06:00
parent 4c4bedb492
commit d89a3adb89
2 changed files with 110 additions and 134 deletions
-26
View File
@@ -57,31 +57,6 @@ partial class Lexer
input = Parse.Char('=').Token()(input).Remainder;
// Types that can't be encoded as simple strings, such as FlowLayout,
// are defined inline using XML elements.
bool isInlineXml = Parse.Char('<')(input).WasSuccessful;
if (isInlineXml)
{
// Find the end of the XML tag
var xmlPartResult = Parse.AnyChar.Until(Parse.String("/>")).Text()(input);
input = xmlPartResult.Remainder;
if (!xmlPartResult.WasSuccessful)
return Result.Failure<IDirective>(input, "Invalid constant directive", ["Expected valid XML"]);
var xmlElem = System.Xml.Linq.XElement.Parse($"{xmlPartResult.Value}/>");
var xmlPrefix = xmlElem.Name.NamespaceName == string.Empty
? null : xmlElem.Name.NamespaceName;
QualifiedTypeName typeName = new(xmlPrefix, xmlElem.Name.LocalName);
var content = xmlElem.ToString(System.Xml.Linq.SaveOptions.DisableFormatting);
directive = new ConstantDirective(constNameResult.Value, typeName, content)
{
Line = line,
};
}
else
{
var typeNameResult = QualifiedTypeName.Token()(input);
input = typeNameResult.Remainder;
if (!typeNameResult.WasSuccessful)
@@ -201,7 +176,6 @@ partial class Lexer
{
return Result.Failure<IDirective>(input, "Invalid constant directive", [$"Invalid persist mode"]);
}
}
break;
case "EXPORT":
+2
View File
@@ -32,6 +32,8 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="System.Memory" Version="4.6.0" />
</ItemGroup>
</Project>