private void TranspileVarNamesPropertyList(sphereScript99Parser.PropertyListContext context)
        {
            if (context.NEWLINE() != null)
            {
                dataBuilder.Append(context.NEWLINE().GetText());
            }

            if (context.propertyAssignment() == null)
            {
                return;
            }

            foreach (var assignment in context.propertyAssignment())
            {
                var name  = assignment.propertyName().GetText();
                var value = assignment.propertyValue()?.GetText();

                if (SharpStriper.TryStrip(value, out string strippedValue))
                {
                    dataVisitor.AppendPropertyAssignment(assignment, strippedValue);
                }
                else
                {
                    dataVisitor.AppendPropertyAssignment(assignment);
                }
            }

            dataBuilder.EnsureNewline();
        }
Esempio n. 2
0
        private void CheckStructure(string expectedResult, string src)
        {
            sphereScript99Parser.PropertyListContext propertyList = null;

            Parse(src, parser =>
            {
                propertyList = parser.propertyList();
            });

            var extractor = new PropertyAndTriggerExtractor();

            extractor.Visit(propertyList);

            extractor.Output.Should().Be(expectedResult);
        }
Esempio n. 3
0
        public override bool VisitPropertyList([NotNull] sphereScript99Parser.PropertyListContext context)
        {
            var assignmentList = context.propertyAssignment();

            if (assignmentList != null)
            {
                output.Append($"props:{assignmentList.Length};");
            }
            else
            {
                output.Append("props:0;");
            }

            return(base.VisitPropertyList(context));
        }
Esempio n. 4
0
 public override bool VisitPropertyList([NotNull] sphereScript99Parser.PropertyListContext context)
 {
     return(parentVisitor.Visit(context));
 }
Esempio n. 5
0
        public override bool VisitPropertyList([NotNull] sphereScript99Parser.PropertyListContext context)
        {
            if (context.NEWLINE() != null)
            {
                builder.Append(context.NEWLINE().GetText());
            }

            if (context.propertyAssignment() == null)
            {
                return(true);
            }

            uint?flagValue = null;
            uint?attrValue = null;

            foreach (var assignment in context.propertyAssignment())
            {
                var name  = assignment.propertyName().GetText();
                var value = assignment.propertyValue()?.GetText();

                if (invalidPropertyValues.TryGetValue(name, out IReadOnlyCollection <string> invalidValues) && invalidValues.Contains(value))
                {
                    continue;
                }
                if (specificFlagValues.TryGetValue(name, out uint specificFlagValue))
                {
                    if (!value.Equals("0", StringComparison.OrdinalIgnoreCase))
                    {
                        flagValue = flagValue.HasValue ? flagValue.Value | specificFlagValue : specificFlagValue;
                    }
                }
                else if (specificAttrValues.TryGetValue(name, out uint specificAttrValue))
                {
                    if (!value.Equals("0", StringComparison.OrdinalIgnoreCase))
                    {
                        attrValue = attrValue.HasValue ? attrValue.Value | specificAttrValue : specificAttrValue;
                    }
                }
                else if (name.Equals("MORE1", StringComparison.OrdinalIgnoreCase) || name.Equals("MORE2", StringComparison.OrdinalIgnoreCase))
                {
                    parentVisitor.AppendPropertyAssignment(assignment, value.Trim('"'));
                }
                else if (SharpStriper.TryStrip(value, out string strippedValue))
                {
                    parentVisitor.AppendPropertyAssignment(assignment, strippedValue);
                }
                else if (!forbiddenProperties.Contains(name))
                {
                    parentVisitor.AppendPropertyAssignment(assignment);
                }
            }

            builder.EnsureNewline();

            if (flagValue.HasValue)
            {
                builder.AppendLine($"FLAGS=0{flagValue.Value:X8}");
            }
            if (attrValue.HasValue)
            {
                builder.AppendLine($"ATTR=0{attrValue.Value:X8}");
            }

            return(true);
        }