include:"..\..\..\..\Libraries\GacUI\Public\Source\Vlpp.h"
namespace:vczh.whoknows.xmlutility
reflection:system.xmlutility
classPrefix:TestXml
guard:VCZH_PARSING_TESTXML2
parser:ParseDocument(XDocument)
parser:ParseElement(XElement)
grammar:

class Node ambiguous(AmbiguousNode)
{
}

class AmbiguousNode : Node
{
	Node[] items;
}

class Text : Node
{
	token content (TestXmlUnescapeTextFragment);
}

class CData : Node
{
	token content (TestXmlUnescapeCData);
}

class Attribute : Node
{
	token name;
	token value (TestXmlUnescapeAttributeValue);
}

class Comment : Node
{
	token content (TestXmlUnescapeComment);
}

class Element : Node
{
	token name;
	token closingName;
	Attribute[] attributes;
	Node[] subNodes (TestXmlMergeTextFragment);
}

class Instruction : Node
{
	token name;
	Attribute[] attributes;
}

class Document : Node
{
	Instruction[] instructions;
	Comment[] comments;
	Element rootElement;
}

enum DirectEnum
{
	A,B,C,
}

class Animal
{
	enum IndirectEnum
	{
		D,E,F,
	}

	class EmptyClass
	{
	}
	
	class Body
	{
		class Fur
		{
			token title;
		}
	}

	class Leg : Body
	{
		token id;
	}

	class Tail : Body
	{
		token id;
	}

	token name;
}

class Bird : Animal
{
	token id;
}

class Goose : Bird
{
	token title;
}

class Duck : Bird
{
	token title;
}

class BlackHole : Animal.Body.Fur
{
	token id;
}

token INSTRUCTION_OPEN = "/</?";
token INSTRUCTION_CLOSE = "/?/>";
token COMPLEX_ELEMENT_OPEN = "/<//";
token SINGLE_ELEMENT_CLOSE = "///>";
token ELEMENT_OPEN = "/<";
token ELEMENT_CLOSE = "/>";
token EQUAL = "/=";

token NAME = "[a-zA-Z0-9:_/-]+";
token ATTVALUE = """([^""&]|&/l+;)*""";
token COMMENT = "/</!--[^>]*/>";
token CDATA = "/</!/[CDATA/[([^/]]|/][^/]]|/]/][^>])*/]/]/>";
token TEXT = "([^<>""& /r/n/ta-zA-Z0-9:_/-]|&/l+;)+";

discardtoken SPACE = "/s+";

rule Attribute XAttribute = NAME:name "=" ATTVALUE:value as Attribute;
rule Text XText = (NAME:content | EQUAL:content | TEXT:content) as Text;
rule CData XCData = CDATA:content as CData;
rule Comment XComment = COMMENT:content as Comment;
rule Element XElement = "<" NAME:name {XAttribute:attributes} ("/>" | ">" {XSubNode:subNodes} "</" NAME:closingName ">") as Element;
rule Node XSubNode = !XText | !XCData | !XComment | !XElement;
rule Instruction XInstruction = "<?" NAME:name {XAttribute:attributes} "?>" as Instruction;
rule Document XDocument = {XInstruction:instructions | XComment:comments} XElement:rootElement as Document;