
CSharp.runtime.CSharp.Antlr4.Runtime.Atn.DecisionInfo.cs Maven / Gradle / Ivy
Show all versions of antlr4-runtime-testsuite Show documentation
/*
* [The "BSD license"]
* Copyright (c) 2013 Terence Parr
* Copyright (c) 2013 Sam Harwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System.Collections.Generic;
using Antlr4.Runtime.Atn;
using Antlr4.Runtime.Dfa;
using Antlr4.Runtime.Sharpen;
namespace Antlr4.Runtime.Atn
{
/// This class contains profiling gathered for a particular decision.
///
/// This class contains profiling gathered for a particular decision.
///
/// Parsing performance in ANTLR 4 is heavily influenced by both static factors
/// (e.g. the form of the rules in the grammar) and dynamic factors (e.g. the
/// choice of input and the state of the DFA cache at the time profiling
/// operations are started). For best results, gather and use aggregate
/// statistics from a large sample of inputs representing the inputs expected in
/// production before using the results to make changes in the grammar.
///
/// 4.3
public class DecisionInfo
{
///
/// The decision number, which is an index into
///
/// .
///
public readonly int decision;
///
/// The total number of times
///
/// was
/// invoked for this decision.
///
public long invocations;
/// The sum of the lookahead required for SLL prediction for this decision.
///
/// The sum of the lookahead required for SLL prediction for this decision.
/// Note that SLL prediction is used before LL prediction for performance
/// reasons even when
///
/// or
///
/// is used.
///
public long SLL_TotalLook;
///
/// Gets the minimum lookahead required for any single SLL prediction to
/// complete for this decision, by reaching a unique prediction, reaching an
/// SLL conflict state, or encountering a syntax error.
///
///
/// Gets the minimum lookahead required for any single SLL prediction to
/// complete for this decision, by reaching a unique prediction, reaching an
/// SLL conflict state, or encountering a syntax error.
///
public long SLL_MinLook;
///
/// Gets the maximum lookahead required for any single SLL prediction to
/// complete for this decision, by reaching a unique prediction, reaching an
/// SLL conflict state, or encountering a syntax error.
///
///
/// Gets the maximum lookahead required for any single SLL prediction to
/// complete for this decision, by reaching a unique prediction, reaching an
/// SLL conflict state, or encountering a syntax error.
///
public long SLL_MaxLook;
///
/// Gets the
///
/// associated with the event where the
///
/// value was set.
///
public LookaheadEventInfo SLL_MaxLookEvent;
/// The sum of the lookahead required for LL prediction for this decision.
///
/// The sum of the lookahead required for LL prediction for this decision.
/// Note that LL prediction is only used when SLL prediction reaches a
/// conflict state.
///
public long LL_TotalLook;
///
/// Gets the minimum lookahead required for any single LL prediction to
/// complete for this decision.
///
///
/// Gets the minimum lookahead required for any single LL prediction to
/// complete for this decision. An LL prediction completes when the algorithm
/// reaches a unique prediction, a conflict state (for
///
/// , an ambiguity state (for
///
/// , or a syntax error.
///
public long LL_MinLook;
///
/// Gets the maximum lookahead required for any single LL prediction to
/// complete for this decision.
///
///
/// Gets the maximum lookahead required for any single LL prediction to
/// complete for this decision. An LL prediction completes when the algorithm
/// reaches a unique prediction, a conflict state (for
///
/// , an ambiguity state (for
///
/// , or a syntax error.
///
public long LL_MaxLook;
///
/// Gets the
///
/// associated with the event where the
///
/// value was set.
///
public LookaheadEventInfo LL_MaxLookEvent;
///
/// A collection of
///
/// instances describing the
/// context sensitivities encountered during LL prediction for this decision.
///
///
public readonly IList contextSensitivities = new List();
///
/// A collection of
///
/// instances describing the parse errors
/// identified during calls to
///
/// for
/// this decision.
///
///
public readonly IList errors = new List();
///
/// A collection of
///
/// instances describing the
/// ambiguities encountered during LL prediction for this decision.
///
///
public readonly IList ambiguities = new List();
///
/// A collection of
///
/// instances describing the
/// results of evaluating individual predicates during prediction for this
/// decision.
///
///
public readonly IList predicateEvals = new List();
///
/// The total number of ATN transitions required during SLL prediction for
/// this decision.
///
///
/// The total number of ATN transitions required during SLL prediction for
/// this decision. An ATN transition is determined by the number of times the
/// DFA does not contain an edge that is required for prediction, resulting
/// in on-the-fly computation of that edge.
///
/// If DFA caching of SLL transitions is employed by the implementation, ATN
/// computation may cache the computed edge for efficient lookup during
/// future parsing of this decision. Otherwise, the SLL parsing algorithm
/// will use ATN transitions exclusively.
///
///
///
///
public long SLL_ATNTransitions;
///
/// The total number of DFA transitions required during SLL prediction for
/// this decision.
///
///
/// The total number of DFA transitions required during SLL prediction for
/// this decision.
/// If the ATN simulator implementation does not use DFA caching for SLL
/// transitions, this value will be 0.
///
///
///
public long SLL_DFATransitions;
///
/// Gets the total number of times SLL prediction completed in a conflict
/// state, resulting in fallback to LL prediction.
///
///
/// Gets the total number of times SLL prediction completed in a conflict
/// state, resulting in fallback to LL prediction.
/// Note that this value is not related to whether or not
///
/// may be used successfully with a particular
/// grammar. If the ambiguity resolution algorithm applied to the SLL
/// conflicts for this decision produce the same result as LL prediction for
/// this decision,
///
/// would produce the same overall
/// parsing result as
///
/// .
///
public long LL_Fallback;
///
/// The total number of ATN transitions required during LL prediction for
/// this decision.
///
///
/// The total number of ATN transitions required during LL prediction for
/// this decision. An ATN transition is determined by the number of times the
/// DFA does not contain an edge that is required for prediction, resulting
/// in on-the-fly computation of that edge.
///
/// If DFA caching of LL transitions is employed by the implementation, ATN
/// computation may cache the computed edge for efficient lookup during
/// future parsing of this decision. Otherwise, the LL parsing algorithm will
/// use ATN transitions exclusively.
///
///
///
///
public long LL_ATNTransitions;
///
/// The total number of DFA transitions required during LL prediction for
/// this decision.
///
///
/// The total number of DFA transitions required during LL prediction for
/// this decision.
/// If the ATN simulator implementation does not use DFA caching for LL
/// transitions, this value will be 0.
///
///
///
public long LL_DFATransitions;
///
/// Constructs a new instance of the
///
/// class to contain
/// statistics for a particular decision.
///
/// The decision number
public DecisionInfo(int decision)
{
this.decision = decision;
}
public override string ToString()
{
return "{" + "decision=" + decision + ", contextSensitivities=" + contextSensitivities.Count + ", errors=" + errors.Count + ", ambiguities=" + ambiguities.Count + ", SLL_lookahead=" + SLL_TotalLook + ", SLL_ATNTransitions=" + SLL_ATNTransitions + ", SLL_DFATransitions=" + SLL_DFATransitions + ", LL_Fallback=" + LL_Fallback + ", LL_lookahead=" + LL_TotalLook + ", LL_ATNTransitions=" + LL_ATNTransitions + '}';
}
}
}