/// <summary>Checks for a given modifier e.g. 'private' in the given fragment of code.</summary>
		/// <param name="fragment">The fragment to check.</param>
		/// <param name="modifier">The modifier to check for.</param>
		/// <returns>True if this fragment contained the given modifier. The fragment is also removed from the code.</returns>
		public static bool Check(CodeFragment fragment,string modifier){
			if(fragment==null||fragment.GetType()!=typeof(VariableFragment)){
				return false;
			}
			bool result=(((VariableFragment)fragment).Value==modifier);
			if(result){
				fragment.Remove();
			}
			return result;
		}
		/// <summary>Skips over any modifiers found in the given code fragment, returning the first non-modifier fragment found.</summary>
		/// <param name="fragment">The place to start from.</param>
		/// <returns>The first non-modifier fragment found. May be the given fragment if it is not a modifier.</returns>
		public static CodeFragment Skip(CodeFragment fragment){
			if(fragment==null||fragment.GetType()!=typeof(VariableFragment)){
				return fragment;
			}
			VariableFragment vfragment=(VariableFragment)fragment;
			if(vfragment.Value=="private"){
				if(fragment.NextChild==null){
					vfragment.Error("Error: 'private' is an access modifier and it must be followed by something. (e.g. private var i..)");
				}
				return Skip(fragment.NextChild);
			}
			return fragment;
		}
示例#3
0
        /// <summary>Checks for a given modifier e.g. 'private' in the given fragment of code.</summary>
        /// <param name="fragment">The fragment to check.</param>
        /// <param name="modifier">The modifier to check for.</param>
        /// <returns>True if this fragment contained the given modifier. The fragment is also removed from the code.</returns>
        public static bool Check(CodeFragment fragment, string modifier)
        {
            if (fragment == null || fragment.GetType() != typeof(VariableFragment))
            {
                return(false);
            }
            bool result = (((VariableFragment)fragment).Value == modifier);

            if (result)
            {
                fragment.Remove();
            }
            return(result);
        }
示例#4
0
        /// <summary>Skips over any modifiers found in the given code fragment, returning the first non-modifier fragment found.</summary>
        /// <param name="fragment">The place to start from.</param>
        /// <returns>The first non-modifier fragment found. May be the given fragment if it is not a modifier.</returns>
        public static CodeFragment Skip(CodeFragment fragment)
        {
            if (fragment == null || fragment.GetType() != typeof(VariableFragment))
            {
                return(fragment);
            }
            VariableFragment vfragment = (VariableFragment)fragment;

            if (vfragment.Value == "private")
            {
                if (fragment.NextChild == null)
                {
                    vfragment.Error("Error: 'private' is an access modifier and it must be followed by something. (e.g. private var i..)");
                }
                return(Skip(fragment.NextChild));
            }
            return(fragment);
        }