/// <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>(&{x} 'a' | &{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)))); }
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())); } }
/// <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>(&{x} 'a' | &{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))); }
public override string ToString() // for debugging { return(string.Format("la{0} = {1} ({2})", LA, Set.ToString(), Cases.Select(c => c.Set).Join("|"))); }
public override string ToString() // for debugging { return(Set.ToString()); }