상속: IBfsSourceNode
예제 #1
0
        private static void CheckRangeOnRange(BfsEnumRange ra, BfsEnumRange rb, BfsEnumField field)
        {
            if (ra.StartValue > rb.EndValue || rb.StartValue > ra.EndValue)
                return;

            if( ra.EndValue == rb.StartValue &&
                (ra.EndInclusion == BfsInclusionEnum.Excluded || rb.StartInclusion == BfsInclusionEnum.Excluded ))
                return;

            if( rb.EndValue == ra.StartValue &&
                (rb.EndInclusion == BfsInclusionEnum.Excluded || ra.StartInclusion == BfsInclusionEnum.Excluded ))
                return;

            BfsCompiler.ReportError(field.SourceRange, "Intersecting ranges not allowed: '" + ra + "' and '" + rb + "'");
        }
예제 #2
0
        private static void CheckValueOnRange(long val, BfsEnumRange range, BfsEnumField field)
        {
            if ( val < range.StartValue || val > range.EndValue)
                return;

            if (val > range.StartValue && val < range.EndValue)
                BfsCompiler.ReportError(field.SourceRange, "Value intersecting range is not allowed: '" + range + "'");

            if (range.StartInclusion == BfsInclusionEnum.Included && val == range.StartValue
                || range.EndInclusion == BfsInclusionEnum.Included && val == range.EndValue)
                BfsCompiler.ReportError(field.SourceRange, "Value intersecting range is not allowed. Check the inclusion brackets: '" + range + "'");
        }
예제 #3
0
        private void ConvertEnumField(PegNode node, BfsEnum block)
        {
            BfsEnumField field = new BfsEnumField();
            StoreSourceRange(node, field);
            for (PegNode enode = node.child_; enode != null; enode = enode.next_)
            {
                switch (GetNodeId(enode))
                {
                    case EBinaryFileSchemaParser.number:
                        BfsEnumValue enumval = new BfsEnumValue();
                        StoreSourceRange(enode, enumval);
                        enumval.Value = long.Parse(GetNodeText(enode), CultureInfo.InvariantCulture);
                        field.EnumMatch = enumval;
                        break;

                    case EBinaryFileSchemaParser.enumrange:
                        BfsEnumRange enumrange = new BfsEnumRange();
                        StoreSourceRange(enode, enumrange);
                        enumrange.StartValue = long.Parse(GetNodeText(enode.child_.next_), CultureInfo.InvariantCulture);
                        enumrange.EndValue = long.Parse(GetNodeText(enode.child_.next_.next_), CultureInfo.InvariantCulture);
                        enumrange.StartInclusion =
                            (GetNodeText(enode.child_) == "[") ? BfsInclusionEnum.Included : BfsInclusionEnum.Excluded;
                        enumrange.EndInclusion =
                            (GetNodeText(enode.child_.next_.next_.next_) == "]") ? BfsInclusionEnum.Included : BfsInclusionEnum.Excluded;
                        field.EnumMatch = enumrange;
                        break;

                    case EBinaryFileSchemaParser.p_else:
                        field.EnumMatch = new BfsEnumElse();
                        StoreSourceRange(enode, field.EnumMatch);
                        break;

                    case EBinaryFileSchemaParser.action_list:
                        ConvertActionList(enode, field.Actions);
                        break;

                    case EBinaryFileSchemaParser.enumname:
                        field.Alias = GetNodeText(enode);
                        field.AliasSourceRange = GetSourceRange(enode);
                        break;
                }
            }
            block.EnumFields.Add(field);
        }