예제 #1
0
 /// <summary>
 /// Parses the portion of the document at the current position, according to the type.
 /// </summary>
 /// <param name="Document">ASN.1 document being parsed.</param>
 /// <param name="Macro">Macro performing parsing.</param>
 /// <returns>Parsed ASN.1 node.</returns>
 public override Asn1Node Parse(Asn1Document Document, Asn1Macro Macro)
 {
     if (Document.ParseValue() is Values.Asn1BooleanValue Value)
     {
         return(Value);
     }
     else
     {
         throw Document.SyntaxError("Boolean value expected.");
     }
 }
예제 #2
0
        /// <summary>
        /// Parses the portion of the document at the current position, according to the
        /// instructions available in the macro.
        /// </summary>
        /// <param name="Document">ASN.1 document being parsed.</param>
        /// <param name="Macro">Macro being executed.</param>
        /// <returns>Parsed ASN.1 node.</returns>
        public override Asn1Node Parse(Asn1Document Document, Asn1Macro Macro)
        {
            switch (this.Identifier.ToUpper())
            {
            case "TYPE": return(Document.ParseType(this.Identifier, false));

            case "VALUE": return(Document.ParseValue());

            default: return(this.type.Parse(Document, Macro));
            }
        }
예제 #3
0
 /// <summary>
 /// Parses the portion of the document at the current position, according to the type.
 /// </summary>
 /// <param name="Document">ASN.1 document being parsed.</param>
 /// <param name="Macro">Macro performing parsing.</param>
 /// <returns>Parsed ASN.1 node.</returns>
 public override Asn1Node Parse(Asn1Document Document, Asn1Macro Macro)
 {
     if (Document.ParseValue() is Values.Asn1FloatingPointValue Value)
     {
         return(Value);
     }
     else
     {
         throw Document.SyntaxError("String value expected.");
     }
 }
예제 #4
0
        /// <summary>
        /// Parses the portion of the document at the current position, according to the
        /// instructions available in the macro.
        /// </summary>
        /// <param name="Document">ASN.1 document being parsed.</param>
        /// <param name="Macro">Macro being executed.</param>
        /// <returns>Parsed ASN.1 node.</returns>
        public override Asn1Node Parse(Asn1Document Document, Asn1Macro Macro)
        {
            if (Macro.Document.namedNodes.TryGetValue(this.identifier, out Asn1Node Node))
            {
                if (Node is Asn1TypeDefinition TypeDef)
                {
                    return(TypeDef.Definition.Parse(Document, Macro));
                }
                else if (Node is Asn1Type Type)
                {
                    return(Type.Parse(Document, Macro));
                }
                else if (Node is Asn1FieldDefinition FieldDef)
                {
                    return(FieldDef.Type.Parse(Document, Macro));
                }
                else
                {
                    throw Document.SyntaxError("Type reference expected: " + this.identifier);
                }
            }

            if (Macro.supportingSyntax.TryGetValue(this.identifier, out SupportingSyntax Syntax))
            {
                return(Syntax.Parse(Document, Macro));
            }

            switch (this.identifier.ToLower())
            {
            case "empty": return(null);

            case "type": return(Document.ParseType(this.Identifier, false));

            case "value": return(Document.ParseValue());

            default: throw Document.SyntaxError("Supporting syntax for " + this.identifier + " not found.");
            }
        }
예제 #5
0
 /// <summary>
 /// Parses the portion of the document at the current position, according to the type.
 /// </summary>
 /// <param name="Document">ASN.1 document being parsed.</param>
 /// <param name="Macro">Macro performing parsing.</param>
 /// <returns>Parsed ASN.1 node.</returns>
 public override Asn1Node Parse(Asn1Document Document, Asn1Macro Macro)
 {
     return(Document.ParseValue());
 }
예제 #6
0
        /// <summary>
        /// Parses the portion of the document at the current position, according to the type.
        /// </summary>
        /// <param name="Document">ASN.1 document being parsed.</param>
        /// <param name="Macro">Macro performing parsing.</param>
        /// <returns>Parsed ASN.1 node.</returns>
        public override Asn1Node Parse(Asn1Document Document, Asn1Macro Macro)
        {
            Asn1Value Value = Document.ParseValue();

            return Value;
        }