27 lines
875 B
C#
27 lines
875 B
C#
using Sprache;
|
|
|
|
namespace XNeedle.Parser
|
|
{
|
|
public class XmlFragParser
|
|
{
|
|
public static Parser<string> OpeningTagAnchor(string tag)
|
|
{
|
|
return
|
|
from lbraket in Parse.Char('<')
|
|
from tagname in Parse.String(tag)
|
|
from any in Parse.CharExcept('>').Many()
|
|
from rbraket in Parse.Char('>')
|
|
select new string([.. any]);
|
|
}
|
|
public static Parser<string> ChecksumData(string opening, string closing)
|
|
{
|
|
return
|
|
from pregarbage in Parse.AnyChar.Many()
|
|
from preamble in Parse.String(opening).Token()
|
|
from content in Parse.AnyChar.Many()
|
|
from epilouge in Parse.String("</" + closing + ">")
|
|
from postgarbage in Parse.AnyChar.Many()
|
|
select new string([.. content]) + epilouge;
|
|
}
|
|
}
|
|
} |