/// <summary>
 /// Parses the node's Name into words.
 /// </summary>
 /// <param name="splitter"></param>
 public virtual void Parse(IdSplitter splitter)
 {
     if (ParsedName == null)
     {
         ParsedName = new PhraseNode(Name, splitter);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates a new VariableDeclarationNode.
 /// </summary>
 /// <param name="name">The name of the variable.</param>
 /// <param name="type">A string giving the type of the variable.</param>
 /// <param name="isPrimitive">Whether the type is a primitive data type.</param>
 /// <param name="splitter">An IdSplitter to split the name into words.</param>
 /// <param name="tagger">A part-of-speech tagger to tag the words in the name.</param>
 /// <param name="location">The program location of the variable declaration.</param>
 /// <param name="position">The position of this variable in the declaration list.</param>
 public VariableDeclarationNode(string name, string type, bool isPrimitive, IdSplitter splitter, Tagger tagger, Location location, int position)
     : this(name, splitter) {
     this.InitType(type, isPrimitive, splitter, tagger);
     //tagger.TagVariableName(this.ParsedName);
     this.SetLocation(location);
     this.Position = position;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Creates a new TypeNode.
 /// </summary>
 /// <param name="name">The name of the type.</param>
 /// <param name="isPrimitive">Whether the type is a primitive data type.</param>
 /// <param name="splitter">An IdSplitter to split the type name into words.</param>
 /// <param name="tagger">A Tagger to tag the parts-of-speech of each word of the name.</param>
 /// <param name="location">The location of the type.</param>
 public TypeNode(string name, bool isPrimitive, IdSplitter splitter, Tagger tagger, Location location)
     : this(name, isPrimitive, splitter) {
     if(tagger != null) {
         tagger.TagType(this.ParsedName);
     }
     this.SetLocation(location);
 }
 /// <summary>
 /// Creates a new VariableDeclarationNode.
 /// </summary>
 /// <param name="name">The name of the variable.</param>
 /// <param name="type">A string giving the type of the variable.</param>
 /// <param name="isPrimitive">Whether the type is a primitive data type.</param>
 /// <param name="splitter">An IdSplitter to split the name into words.</param>
 /// <param name="tagger">A part-of-speech tagger to tag the words in the name.</param>
 /// <param name="location">The program location of the variable declaration.</param>
 /// <param name="position">The position of this variable in the declaration list.</param>
 public VariableDeclarationNode(string name, string type, bool isPrimitive, IdSplitter splitter, Tagger tagger, Location location, int position)
     : this(name, splitter)
 {
     this.InitType(type, isPrimitive, splitter, tagger);
     //tagger.TagVariableName(this.ParsedName);
     this.SetLocation(location);
     this.Position = position;
 }
 /// <summary>
 /// Creates a new TypeNode.
 /// </summary>
 /// <param name="name">The name of the type.</param>
 /// <param name="isPrimitive">Whether the type is a primitive data type.</param>
 /// <param name="splitter">An IdSplitter to split the type name into words.</param>
 /// <param name="tagger">A Tagger to tag the parts-of-speech of each word of the name.</param>
 /// <param name="location">The location of the type.</param>
 public TypeNode(string name, bool isPrimitive, IdSplitter splitter, Tagger tagger, Location location)
     : this(name, isPrimitive, splitter)
 {
     if (tagger != null)
     {
         tagger.TagType(this.ParsedName);
     }
     this.SetLocation(location);
 }
        /// <summary>
        /// Creates a new PhraseNode that contains the words resulting from splitting the given identifier.
        /// </summary>
        /// <param name="id">A program identifier.</param>
        /// <param name="splitter">An IdSplitter to split the given identifier into words.</param>
        public PhraseNode(string id, IdSplitter splitter)
            : this()
        {
            string[] words;
            if (splitter != null)
            {
                words = splitter.Split(id);
            }
            else
            {
                words = new string[] { id };
            }

            InitWords(words);
        }
        //TODO: should this be a separate function, or integrated into the constructor? This occurs in other nodes as well
        /// <summary>
        /// Initializes the fields containing structural information about the method. This includes the location, return type and parameters.
        /// </summary>
        /// <param name="splitter">An IdSplitter to split the method name into words.</param>
        /// <param name="tagger">A Tagger to tag the parts-of-speech of the name.</param>
        /// <exception cref="System.ArgumentNullException">splitter is null.</exception>
        /// <exception cref="System.ArgumentNullException">tagger is null.</exception>
        /// <exception cref="System.InvalidOperationException">Context property is not set.</exception>
        public void AssignStructuralInformation(IdSplitter splitter, Tagger tagger)
        {
            if (splitter == null)
            {
                throw new ArgumentNullException("splitter");
            }
            if (tagger == null)
            {
                throw new ArgumentNullException("tagger");
            }
            if (this.Context == null)
            {
                throw new InvalidOperationException("Context property must be set prior to calling AssignStructuralInformation");
            }

            this.ParsedName.SetLocation(Location.Name);
            if (!string.IsNullOrEmpty(Context.IdType))
            {
                this.ReturnType = new TypeNode(Context.IdType, Context.IdTypeIsPrimitive, splitter, tagger, Location.Return);
            }
            if (!string.IsNullOrEmpty(Context.DeclaringClass))
            {
                this.DeclaringClass = new TypeNode(Context.DeclaringClass, false, splitter, tagger, Location.OnClass);
            }

            this.FormalParameters = new List <VariableDeclarationNode>();
            if (Context.FormalParameters.Count > 0)
            {
                int pos = 0;
                foreach (FormalParameterRecord paramRecord in Context.FormalParameters)
                {
                    this.FormalParameters.Add(new VariableDeclarationNode(paramRecord.Name, paramRecord.ParameterType, paramRecord.IsPrimitiveType, splitter, tagger, Location.Formal, pos));
                    pos++;
                }
            }
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Creates a new VariableDeclarationNode.
 /// </summary>
 /// <param name="name">The name of the variable.</param>
 /// <param name="splitter">An IdSplitter to split the name into words.</param>
 public VariableDeclarationNode(string name, IdSplitter splitter) : base(name, splitter) { }
 /// <summary>
 /// Creates a new TypeNode.
 /// </summary>
 /// <param name="name">The name of the type.</param>
 /// <param name="isPrimitive">Whether the type is a primitive data type.</param>
 /// <param name="splitter">An IdSplitter to split the type name into words.</param>
 public TypeNode(string name, bool isPrimitive, IdSplitter splitter)
     : base(name, splitter)
 {
     this.IsPrimitive = isPrimitive;
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Creates a new TypeNode.
 /// </summary>
 /// <param name="name">The name of the type.</param>
 /// <param name="isPrimitive">Whether the type is a primitive data type.</param>
 /// <param name="splitter">An IdSplitter to split the type name into words.</param>
 /// <param name="tagger">A Tagger to tag the parts-of-speech of each word of the name.</param>
 public TypeNode(string name, bool isPrimitive, IdSplitter splitter, Tagger tagger)
     : this(name, isPrimitive, splitter, tagger, Location.None)
 {
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Creates a TypeNode from a string version of the type, and set it to the Type property.
 /// </summary>
 /// <param name="typeName">A string version of the variable's type.</param>
 /// <param name="isPrimitive">Whether the type is a primitive data type.</param>
 /// <param name="splitter">An IdSplitter to split the type into words.</param>
 /// <param name="tagger">A Tagger to tag the parts-of-speech of the type words.</param>
 protected virtual void InitType(string typeName, bool isPrimitive, IdSplitter splitter, Tagger tagger) {
     this.Type = new TypeNode(typeName, isPrimitive, splitter, tagger);
 }
 /// <summary>
 /// Assigns the attributes of this field related to its structure within the program.
 /// </summary>
 /// <param name="splitter">An IdSplitter to split the words of identifiers.</param>
 /// <param name="tagger">A part-of-speech tagger</param>
 public void AssignStructuralInformation(IdSplitter splitter, Tagger tagger)
 {
     this.Type           = new TypeNode(Context.IdType, Context.IdTypeIsPrimitive, splitter, tagger);
     this.DeclaringClass = new TypeNode(Context.DeclaringClass, false, splitter, tagger);
 }
 /// <summary>
 /// Creates a new VariableDeclarationNode.
 /// </summary>
 /// <param name="name">The name of the variable.</param>
 /// <param name="splitter">An IdSplitter to split the name into words.</param>
 public VariableDeclarationNode(string name, IdSplitter splitter) : base(name, splitter)
 {
 }
 /// <summary>
 /// Creates a new VariableDeclarationNode.
 /// </summary>
 /// <param name="name">The name of the variable.</param>
 /// <param name="type">A string giving the type of the variable.</param>
 /// <param name="isPrimitive">Whether the type is a primitive data type.</param>
 /// <param name="splitter">An IdSplitter to split the name into words.</param>
 /// <param name="tagger">A part-of-speech tagger to tag the words in the name.</param>
 /// <param name="location">The program location of the variable declaration.</param>
 public VariableDeclarationNode(string name, string type, bool isPrimitive, IdSplitter splitter, Tagger tagger, Location location)
     : this(name, type, isPrimitive, splitter, tagger, location, 0)
 {
 }
Ejemplo n.º 15
0
        //TODO: should this be a separate function, or integrated into the constructor? This occurs in other nodes as well
        /// <summary>
        /// Initializes the fields containing structural information about the method. This includes the location, return type and parameters.
        /// </summary>
        /// <param name="splitter">An IdSplitter to split the method name into words.</param>
        /// <param name="tagger">A Tagger to tag the parts-of-speech of the name.</param>
        /// <exception cref="System.ArgumentNullException">splitter is null.</exception>
        /// <exception cref="System.ArgumentNullException">tagger is null.</exception>
        /// <exception cref="System.InvalidOperationException">Context property is not set.</exception>
        public void AssignStructuralInformation(IdSplitter splitter, Tagger tagger) {
            if(splitter == null) { throw new ArgumentNullException("splitter"); }
            if(tagger == null) { throw new ArgumentNullException("tagger"); }
            if(this.Context == null) { throw new InvalidOperationException("Context property must be set prior to calling AssignStructuralInformation"); }

            this.ParsedName.SetLocation(Location.Name);
            if(!string.IsNullOrEmpty(Context.IdType)) {
                this.ReturnType = new TypeNode(Context.IdType, Context.IdTypeIsPrimitive, splitter, tagger, Location.Return);
            }
            if(!string.IsNullOrEmpty(Context.DeclaringClass)) {
                this.DeclaringClass = new TypeNode(Context.DeclaringClass, false, splitter, tagger, Location.OnClass);
            }

            this.FormalParameters = new List<VariableDeclarationNode>();
            if(Context.FormalParameters.Count > 0) {
                int pos = 0;
                foreach(FormalParameterRecord paramRecord in Context.FormalParameters) {
                    this.FormalParameters.Add(new VariableDeclarationNode(paramRecord.Name, paramRecord.ParameterType, paramRecord.IsPrimitiveType, splitter, tagger, Location.Formal, pos));
                    pos++;
                }
            }
        }
 /// <summary>
 /// Creates a TypeNode from a string version of the type, and set it to the Type property.
 /// </summary>
 /// <param name="typeName">A string version of the variable's type.</param>
 /// <param name="isPrimitive">Whether the type is a primitive data type.</param>
 /// <param name="splitter">An IdSplitter to split the type into words.</param>
 /// <param name="tagger">A Tagger to tag the parts-of-speech of the type words.</param>
 protected virtual void InitType(string typeName, bool isPrimitive, IdSplitter splitter, Tagger tagger)
 {
     this.Type = new TypeNode(typeName, isPrimitive, splitter, tagger);
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Assigns the attributes of this field related to its structure within the program.
 /// </summary>
 /// <param name="splitter">An IdSplitter to split the words of identifiers.</param>
 /// <param name="tagger">A part-of-speech tagger</param>
 public void AssignStructuralInformation(IdSplitter splitter, Tagger tagger) {
     this.Type = new TypeNode(Context.IdType, Context.IdTypeIsPrimitive, splitter, tagger);
     this.DeclaringClass = new TypeNode(Context.DeclaringClass, false, splitter, tagger);
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Creates a new VariableDeclarationNode.
 /// </summary>
 /// <param name="name">The name of the variable.</param>
 /// <param name="type">A string giving the type of the variable.</param>
 /// <param name="isPrimitive">Whether the type is a primitive data type.</param>
 /// <param name="splitter">An IdSplitter to split the name into words.</param>
 /// <param name="tagger">A part-of-speech tagger to tag the words in the name.</param>
 /// <param name="location">The program location of the variable declaration.</param>
 public VariableDeclarationNode(string name, string type, bool isPrimitive, IdSplitter splitter, Tagger tagger, Location location)
     : this(name, type, isPrimitive, splitter, tagger, location, 0) { }
 /// <summary>
 /// Creates a new ProgramElementNode and sets Name to the supplied value. Name is then parsed using the supplied IdSplitter.
 /// </summary>
 /// <param name="name">The name of the program element.</param>
 /// <param name="splitter">An IdSplitter to use to parse the name.</param>
 public ProgramElementNode(string name, IdSplitter splitter)
     : this(name) {
     Parse(splitter);
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Creates a new TypeNode.
 /// </summary>
 /// <param name="name">The name of the type.</param>
 /// <param name="isPrimitive">Whether the type is a primitive data type.</param>
 /// <param name="splitter">An IdSplitter to split the type name into words.</param>
 public TypeNode(string name, bool isPrimitive, IdSplitter splitter)
     : base(name, splitter) {
     this.IsPrimitive = isPrimitive;
 }
Ejemplo n.º 21
0
 /// <summary>
 /// Creates a new TypeNode.
 /// </summary>
 /// <param name="name">The name of the type.</param>
 /// <param name="isPrimitive">Whether the type is a primitive data type.</param>
 /// <param name="splitter">An IdSplitter to split the type name into words.</param>
 /// <param name="tagger">A Tagger to tag the parts-of-speech of each word of the name.</param>
 public TypeNode(string name, bool isPrimitive, IdSplitter splitter, Tagger tagger)
     : this(name, isPrimitive, splitter, tagger, Location.None) { }