Esempio n. 1
0
        /// <summary>
        /// Constructs a new DottedIdentifier
        /// </summary>
        /// <param name="table">Identifier table that will store this identifier.</param>
        /// <param name="prefix">The prefix of the identifier</param>
        /// <param name="tail">The tail of the identifier</param>
        public DottedIdentifier(SymbolTable table, IEnumerable <string> prefix, DottedIdentifier tail)
        {
            Contract.RequiresNotNull(table);
            Contract.RequiresNotNull(prefix);

            // we'll need this argument in the future so prevent warnings until then.
            Analysis.IgnoreArgument(table);

            DottedIdentifier current = null;

            foreach (var s in prefix)
            {
                if (current == null)
                {
                    // head node
                    Head    = SymbolAtom.Create(table.StringTable, (StringSegment)s);
                    current = this;
                }
                else
                {
                    // extend the tail
                    current.m_tail = new DottedIdentifier(table, s);
                    current        = current.m_tail;
                }
            }

            Contract.AssertNotNull(current, "Must have at least one element in the prefix enumeration");
            current.m_tail = tail;
        }
Esempio n. 2
0
        /// <summary>
        /// Constructs a new DottedIdentifier
        /// </summary>
        /// <param name="table">Identifier table that will store this identifier.</param>
        /// <param name="components">The components of the identifier</param>
        public DottedIdentifier(SymbolTable table, IEnumerable <string> components)
        {
            Contract.RequiresNotNull(table);
            Contract.RequiresNotNull(components);

            DottedIdentifier current = null;

            foreach (var s in components)
            {
                if (current == null)
                {
                    // head node
                    Head    = SymbolAtom.Create(table.StringTable, (StringSegment)s);
                    current = this;
                }
                else
                {
                    // extend the tail
                    current.m_tail = new DottedIdentifier(table, s);
                    current        = current.m_tail;
                }
            }

            Contract.AssertNotNull(current, "Must have at least one element in the components enumeration");
        }
Esempio n. 3
0
        public static DottedIdentifier Create <TChars>(SymbolTable table, TChars head, DottedIdentifier tail = null)
            where TChars : struct, ICharSpan <TChars>
        {
            Contract.RequiresNotNull(table);
            Contract.Requires(head.Length != 0);

            return(new DottedIdentifier(SymbolAtom.Create(table.StringTable, head), tail));
        }
Esempio n. 4
0
        /// <summary>
        /// Reads a SymbolAtom from a string representation
        /// </summary>
        public override SymbolAtom ReadSymbolAtom()
        {
            Start <SymbolAtom>();
            var        isValid = ReadBoolean();
            SymbolAtom value   = isValid ? SymbolAtom.Create(m_stringTable, ReadString()) : SymbolAtom.Invalid;

            End();
            return(value);
        }
Esempio n. 5
0
        /// <summary>
        /// Constructs a new DottedIdentifier
        /// </summary>
        /// <param name="table">Identifier table that will store this identifier.</param>
        /// <param name="head">The head of the identifier</param>
        public DottedIdentifier(SymbolTable table, string head)
        {
            Contract.RequiresNotNull(table);
            Contract.RequiresNotNullOrEmpty(head);

            StringSegment seg = head;

            Contract.Assert(seg.Length > 0);

            Head = SymbolAtom.Create(table.StringTable, seg);
        }