예제 #1
0
        /// <summary>Generates code for the default error branch of prediction
        /// (called when there is no explicit error branch).</summary>
        /// <param name="covered">The permitted token set, which the input did not match.
        /// NOTE: if the input matched but there were and-predicates that did not match,
        /// this parameter will be null (e.g. the input is 'b' in <c>(&amp;{x} 'a' | &amp;{y} 'b')</c>,
        /// but y is false.</param>
        /// <param name="laIndex">Location of unexpected input, relative to current position.</param>
        public virtual LNode ErrorBranch(IPGTerminalSet covered, int laIndex)
        {
            string coveredS = covered.ToString();

            if (coveredS.Length > 45)
            {
                coveredS = coveredS.Substring(0, 40) + "...";
            }
            return(ApiCall(_Error, F.Literal(laIndex),
                           F.Literal(string.Format("In rule '{0}', expected one of: {1}", _currentRule.Name.Name, coveredS))));
        }
예제 #2
0
            public override string ToString()             // for debugging
            {
                string andPreds = "";

                if (AndPreds != null)
                {
                    andPreds = StringExt.Join(" || ", AndPreds.Select(set_ => StringExt.Join("", set_)));
                }
                string set = Set == null ? "" : Set.ToString();

                if (andPreds == "" && (set == "" || set == "[^]"))
                {
                    return(string.Format("otherwise, {0}", Sub.ToString()));
                }
                else
                {
                    return(string.Format("when {0} {1}, {2}", andPreds, set, Sub.ToString()));
                }
            }
예제 #3
0
		/// <summary>Generates code for the default error branch of prediction
		/// (called when there is no explicit error branch).</summary>
		/// <param name="covered">The permitted token set, which the input did not match. 
		/// NOTE: if the input matched but there were and-predicates that did not match,
		/// this parameter will be null (e.g. the input is 'b' in <c>(&amp;{x} 'a' | &amp;{y} 'b')</c>,
		/// but y is false.</param>
		/// <param name="laIndex">Location of unexpected input, relative to current position.</param>
		public virtual LNode ErrorBranch(IPGTerminalSet covered, int laIndex)
		{
			string coveredS = covered.ToString();
			if (coveredS.Length > 45)
				coveredS = coveredS.Substring(0, 40) + "...";
			return ApiCall(_Error, F.Literal(laIndex),
				F.Literal(string.Format("In rule '{0}', expected one of: {1}", _currentRule.Name.Name, coveredS)));
		}
예제 #4
0
 public override string ToString()             // for debugging
 {
     return(string.Format("la{0} = {1} ({2})", LA, Set.ToString(), Cases.Select(c => c.Set).Join("|")));
 }
예제 #5
0
파일: Predicates.cs 프로젝트: dadhi/ecsharp
 public override string ToString()         // for debugging
 {
     return(Set.ToString());
 }