Beispiel #1
0
 public MetadataNode(SourceToken InTag, SourceToken InTokenValue)
 {
     Tag        = InTag;
     TokenValue = InTokenValue;
 }
Beispiel #2
0
 public MetadataNode(SourceToken InTag, List <MetadataNode> InListValue)
 {
     Tag       = InTag;
     ListValue = InListValue;
 }
Beispiel #3
0
 public MetadataNode(SourceToken InTag, List<MetadataNode> InListValue)
 {
     Tag = InTag;
     ListValue = InListValue;
 }
Beispiel #4
0
 public MetadataNode(SourceToken InTag)
 {
     Tag = InTag;
 }
Beispiel #5
0
 public MetadataNode(SourceToken InTag, SourceToken InTokenValue)
 {
     Tag = InTag;
     TokenValue = InTokenValue;
 }
Beispiel #6
0
 public MetadataNode(SourceToken InTag)
 {
     Tag = InTag;
 }
Beispiel #7
0
        public static List<MetadataNode> TryParseNodeList(SourceToken[] Tokens, ref int Index)
        {
            List<MetadataNode> Nodes = null;
            if(Tokens[Index].Text == "(")
            {
                Nodes = new List<MetadataNode>();

                int NewIndex = Index + 1;
                if (Tokens[NewIndex].Text != ")")
                {
                    for (; ; )
                    {
                        // Read the next node
                        MetadataNode Node = TryParseNode(Tokens, ref NewIndex);
                        if (Node == null) throw new NotImplementedException();

                        // Append it to the list
                        Nodes.Add(Node);

                        // Read the next delimiting comma
                        if (Tokens[NewIndex].Text == ")") break;
                        if (Tokens[NewIndex].Text != ",") throw new NotImplementedException();
                        NewIndex++;
                    }
                }
                Index = NewIndex + 1;
            }
            return Nodes;
        }
Beispiel #8
0
        public static MetadataNode TryParseNode(SourceToken[] Tokens, ref int Index)
        {
            MetadataNode Node = null;
            if(Tokens[Index].IsIdentifier)
            {
                int NewIndex = Index + 1;

                // Check whether it has a value
                if (Tokens[NewIndex].Text == "=" || Tokens[NewIndex].Text == "(")
                {
                    if(Tokens[NewIndex].Text == "=") NewIndex++;

                    List<MetadataNode> NodeList = TryParseNodeList(Tokens, ref NewIndex);
                    if (NodeList != null)
                    {
                        Node = new MetadataNode(Tokens[Index], NodeList);
                        Index = NewIndex;
                    }
                    else if(Tokens[NewIndex].IsIdentifier || Tokens[NewIndex].IsLiteral)
                    {
                        Node = new MetadataNode(Tokens[Index], Tokens[NewIndex]);
                        Index = NewIndex + 1;
                    }
                }
                else
                {
                    Node = new MetadataNode(Tokens[Index]);
                    Index = NewIndex;
                }
            }
            else if (Tokens[Index].IsLiteral)
            {
                Node = new MetadataNode(Tokens[Index]);
                Index++;
            }
            return Node;
        }
Beispiel #9
0
        public static MetadataDirective TryParseDirective(SourceFile File, SourceToken[] Tokens, int Index)
        {
            string TagText = Tokens[Index].Text;
            if(TagText == "UCLASS" || TagText == "UPROPERTY" || TagText == "UENUM" || TagText == "USTRUCT" || TagText == "UFUNCTION")
            {
                int DirectiveIndex = Index++;

                List<MetadataNode> NodeList = TryParseNodeList(Tokens, ref Index);
                if(NodeList != null)
                {
                    // Save the end of the metadata, and the start of the definition
                    int DirectiveEndIndex = Index;

                    // Depending on the type, parse a definition
                    int DefinitionIndex = Index;
                    if(TagText == "UCLASS" || TagText == "USTRUCT" || TagText == "UENUM")
                    {
                        for(; Index < Tokens.Length && Tokens[Index].Text != ";"; Index++)
                        {
                            if(Tokens[Index].Text == "{")
                            {
                                DefinitionIndex = Index + 1;
                                break;
                            }
                        }
                    }

                    // Create the definition
                    return new MetadataDirective(File, DirectiveIndex, DirectiveEndIndex, DefinitionIndex, NodeList);
                }
            }
            return null;
        }