Пример #1
0
        public static UIGroup FromReduction(GOLDEngine.Reduction r, Dictionary<Token, object> dataMap)
        {
            UIGroup result = new UIGroup();
            // <Object> ::= BeginLiteral <Content> EndLiteral
            var content = (List<UINode>)dataMap[r[1]];
            var sharedProps = content.FirstOrDefault(x => x.Name == "SetSharedProperties");

            result.SharedProperties = sharedProps;
            result.Children = content.Where(x => x != sharedProps).ToList();

            return result;
        }
Пример #2
0
        public static UIGroup FromReduction(GOLD.Reduction r)
        {
            UIGroup result = new UIGroup();
            // <Object> ::= BeginLiteral <Content> EndLiteral
            var content = (List<UINode>)r.get_Data(1);
            var sharedProps = content.FirstOrDefault(x => x.Name == "SetSharedProperties");

            result.SharedProperties = sharedProps;
            result.Children = content.Where(x => x != sharedProps).ToList();

            return result;
        }
Пример #3
0
 public void Process(UIGroup content)
 {
     /** Pre-Process **/
     PreProcessUIGroup(content, new Dictionary <string, string>());
     ProcessUIGroup(content);
 }
Пример #4
0
        private object CreateNewObject(GOLDEngine.Reduction r)
        {
            object result = r.ToText();

            for (int i = 0; i < r.Count; i++)
            {
                if (!DataMap.ContainsKey(r[i]))
                {
                    DataMap[r[i]] = r[i].ToText();
                }
            }

            switch ((ProductionIndex)r.Production.TableIndex())
            {
            case ProductionIndex.Objects:
                var newResult = new List <UINode>();
                newResult.Add((UINode)DataMap[r[0]]);
                newResult.AddRange((List <UINode>)DataMap[r[1]]);
                result  = newResult;
                program = result;
                // <Objects> ::= <Object> <Objects>
                break;

            case ProductionIndex.Objects2:
                // <Objects> ::= <Object>
                var newResult2 = new List <UINode>();
                newResult2.Add((UINode)DataMap[r[0]]);
                result  = newResult2;
                program = result;
                break;

            case ProductionIndex.Object_Beginliteral_Endliteral:
                // <Object> ::= BeginLiteral <Content> EndLiteral
                result = UIGroup.FromReduction(r, DataMap);
                break;

            case ProductionIndex.Object:
                // <Object> ::= <Start Tag>
                result = DataMap[r[0]];
                break;

            case ProductionIndex.Object2:
                // <Object> ::= <Unary Tag>
                break;

            case ProductionIndex.Starttag_Lt_Id_Gt:
                // <Start Tag> ::= '<' ID <OptionalID> <Attributes> '>'
                var node = new UINode();
                node.Name = (string)DataMap[r[1]];
                node.ID   = (string)DataMap[r[2]];
                var atts = (List <KeyValuePair <string, string> >)DataMap[r[3]];
                foreach (var att in atts)
                {
                    node[att.Key] = att.Value;
                }
                result = node;
                break;

            case ProductionIndex.Endtag_Ltdiv_Id_Gt:
                // <End Tag> ::= '</' ID '>'
                break;

            case ProductionIndex.Unarytag_Lt_Id_Divgt:
                // <Unary Tag> ::= '<' ID <OptionalID> <Attributes> '/>'
                break;

            case ProductionIndex.Optionalid_Stringliteral:
                // <OptionalID> ::= StringLiteral
                result = GetStringLiteral((string)DataMap[r[0]]);
                break;

            case ProductionIndex.Optionalid:
                // <OptionalID> ::=
                result = null;
                break;

            case ProductionIndex.Content:
                // <Content> ::= <Objects>
                var newResult3 = new List <UINode>();
                newResult3.AddRange((List <UINode>)DataMap[r[0]]);
                result = newResult3;
                break;

            case ProductionIndex.Content2:
                // <Content> ::= <Text>
                var newResult4 = new List <UINode>();
                newResult4.Add((UINode)DataMap[r[0]]);
                result = newResult4;
                break;

            case ProductionIndex.Attributes:
                // <Attributes> ::= <Attribute> <Attributes>
                var attributeList = new List <KeyValuePair <string, string> >();
                attributeList.Add((KeyValuePair <string, string>)DataMap[r[0]]);
                if (r.Count > 1)
                {
                    attributeList.AddRange((List <KeyValuePair <string, string> >)DataMap[r[1]]);
                }
                result = attributeList;
                break;

            case ProductionIndex.Attributes2:
                // <Attributes> ::=
                result = new List <KeyValuePair <string, string> >();
                break;

            case ProductionIndex.Attribute_Id_Eq_Stringliteral:
                // <Attribute> ::= ID '=' StringLiteral
                result = new KeyValuePair <string, string>((string)DataMap[r[0]], GetStringLiteral((string)DataMap[r[2]]));
                break;

            case ProductionIndex.Attribute_Id_Eq_Id:
                // <Attribute> ::= ID '=' ID
                result = new KeyValuePair <string, string>((string)DataMap[r[0]], (string)DataMap[r[2]]);
                break;

            case ProductionIndex.Text:
                // <Text> ::= <Text> <Word>
                break;

            case ProductionIndex.Text2:
                // <Text> ::= <Word>
                break;

            case ProductionIndex.Word_Id:
                // <Word> ::= ID
                break;

            case ProductionIndex.Word_Eq:
                // <Word> ::= '='
                break;

            case ProductionIndex.Word_Charname:
                // <Word> ::= CharName
                break;

            case ProductionIndex.Word_Charnumber:
                // <Word> ::= CharNumber
                break;
            }  //switch

            DataMap[r] = result;
            return(result);
        }
Пример #5
0
        private object CreateNewObject(GOLD.Reduction r)
        {
            object result = r;

            switch ((ProductionIndex)r.Parent.TableIndex())
            {
            case ProductionIndex.Objects:
                var newResult = new List <UINode>();
                newResult.Add((UINode)r.get_Data(0));
                newResult.AddRange((List <UINode>)r.get_Data(1));
                result  = newResult;
                program = result;
                // <Objects> ::= <Object> <Objects>
                break;

            case ProductionIndex.Objects2:
                // <Objects> ::= <Object>
                var newResult2 = new List <UINode>();
                newResult2.Add((UINode)r.get_Data(0));
                result  = newResult2;
                program = result;
                break;

            case ProductionIndex.Object_Beginliteral_Endliteral:
                // <Object> ::= BeginLiteral <Content> EndLiteral
                result = UIGroup.FromReduction(r);
                break;

            case ProductionIndex.Object:
                // <Object> ::= <Start Tag>
                result = r.get_Data(0);
                break;

            case ProductionIndex.Object2:
                // <Object> ::= <Unary Tag>
                break;

            case ProductionIndex.Starttag_Lt_Id_Gt:
                // <Start Tag> ::= '<' ID <OptionalID> <Attributes> '>'
                var node = new UINode();
                node.Name = (string)r.get_Data(1);
                node.ID   = (string)r.get_Data(2);
                var atts = (List <KeyValuePair <string, string> >)r.get_Data(3);
                foreach (var att in atts)
                {
                    node[att.Key] = att.Value;
                }
                result = node;
                break;

            case ProductionIndex.Endtag_Ltdiv_Id_Gt:
                // <End Tag> ::= '</' ID '>'
                break;

            case ProductionIndex.Unarytag_Lt_Id_Divgt:
                // <Unary Tag> ::= '<' ID <OptionalID> <Attributes> '/>'
                break;

            case ProductionIndex.Optionalid_Stringliteral:
                // <OptionalID> ::= StringLiteral
                result = GetStringLiteral((string)r.get_Data(0));
                break;

            case ProductionIndex.Optionalid:
                // <OptionalID> ::=
                result = null;
                break;

            case ProductionIndex.Content:
                // <Content> ::= <Objects>
                var newResult3 = new List <UINode>();
                newResult3.AddRange((List <UINode>)r.get_Data(0));
                result = newResult3;
                break;

            case ProductionIndex.Content2:
                // <Content> ::= <Text>
                var newResult4 = new List <UINode>();
                newResult4.Add((UINode)r.get_Data(0));
                result = newResult4;
                break;

            case ProductionIndex.Attributes:
                // <Attributes> ::= <Attribute> <Attributes>
                var attributeList = new List <KeyValuePair <string, string> >();
                attributeList.Add((KeyValuePair <string, string>)r.get_Data(0));
                if (r.Count() > 1)
                {
                    attributeList.AddRange((List <KeyValuePair <string, string> >)r.get_Data(1));
                }
                result = attributeList;
                break;

            case ProductionIndex.Attributes2:
                // <Attributes> ::=
                result = new List <KeyValuePair <string, string> >();
                break;

            case ProductionIndex.Attribute_Id_Eq_Stringliteral:
                // <Attribute> ::= ID '=' StringLiteral
                result = new KeyValuePair <string, string>((string)r.get_Data(0), GetStringLiteral((string)r.get_Data(2)));
                break;

            case ProductionIndex.Attribute_Id_Eq_Id:
                // <Attribute> ::= ID '=' ID
                result = new KeyValuePair <string, string>((string)r.get_Data(0), (string)r.get_Data(2));
                break;

            case ProductionIndex.Text:
                // <Text> ::= <Text> <Word>
                break;

            case ProductionIndex.Text2:
                // <Text> ::= <Word>
                break;

            case ProductionIndex.Word_Id:
                // <Word> ::= ID
                break;

            case ProductionIndex.Word_Eq:
                // <Word> ::= '='
                break;

            case ProductionIndex.Word_Charname:
                // <Word> ::= CharName
                break;

            case ProductionIndex.Word_Charnumber:
                // <Word> ::= CharNumber
                break;
            }  //switch

            return(result);
        }