public bool Offer(string aLine, long aLineNumber, DExcExtractorList aList, DExcExtractor aInterpreter) { Match m = iExpression.Match(aLine); // if (m.Success) { if (Type == TType.ETypeMatchAndTransition || Type == TType.ETypeMatchSaveAndTransition) { aInterpreter.State = iNewState; } if (Type == TType.ETypeMatchAndSave) { aList.Add(m.Value); } else if (Type == TType.ETypeMatchSaveAndTransition) { // We have just transitioned state and we must add the line // to the new state's list if (aInterpreter.CurrentList != null) { aInterpreter.CurrentList.Add(m.Value); } } } // return(m.Success); }
private DExcExtractorList CreateList(TState aAssociatedState, DExcExtractorListType aType, params Regex[] aExpressions) { DExcExtractorList ret = new DExcExtractorList(aAssociatedState, aType); PrepareList(ret, aExpressions); return(ret); }
public void Init() { iState = TState.EStateIdle; iData = new DExcExtractedData(); iLists = new Dictionary <TState, DExcExtractorList>(); iCurrentLineNumber = 0; // Null (really just exists to catch a state transition) // ======================================================= CreateList(TState.EStateIdle, DExcExtractorListType.EListNull).AddExpression(DExcExtractorEntry.NewMatchSaveAndTransition(EM.LogStart, TState.EStateHeader)); // Header // ======================================================= CreateList(TState.EStateHeader, DExcExtractorListType.EListHeader).AddExpression(DExcExtractorEntry.NewMatchSaveAndTransition(EM.ThreadName, TState.EStateThreadInfo)); // Thread info // =========== DExcExtractorListThreadInfo listThreadInfo = new DExcExtractorListThreadInfo(TState.EStateThreadInfo, DExcExtractorListType.EListThread); PrepareList(listThreadInfo, EM.ThreadName, EM.ThreadId, EM.ThreadStackRange, EM.ThreadPanicDetails); listThreadInfo.AddExpression(DExcExtractorEntry.NewMatchSaveAndTransition(EM.RegistersExceptionStart, TState.EStateRegisterInfoException)); listThreadInfo.AddExpression(DExcExtractorEntry.NewMatchSaveAndTransition(EM.RegistersUserStart, TState.EStateRegisterInfoUser)); // Registers (exception) // ===================== DExcExtractorList listRegisterInfoException = CreateList(TState.EStateRegisterInfoException, DExcExtractorListType.EListRegistersException, EM.RegistersExceptionSet1, EM.RegistersExceptionSet2); listRegisterInfoException.AddExpression(DExcExtractorEntry.NewMatchSaveAndTransition(EM.RegistersUserStart, TState.EStateRegisterInfoUser)); // Registers (user) // ================ DExcExtractorList listRegisterInfoUser = CreateList(TState.EStateRegisterInfoUser, DExcExtractorListType.EListRegistersUser, EM.RegistersUserCPSR, EM.RegistersUserSet); // Since code segs are optional, we want to record that we at least saw the header text (which is mandatory). This // tracking allows us to validate that we have received/observed data for all states. listRegisterInfoUser.AddExpression(DExcExtractorEntry.NewMatchSaveAndTransition(EM.CodeSegmentsStart, TState.EStateCodeSegments)); // Code segments // ============= DExcExtractorList listCodeSegments = CreateList(TState.EStateCodeSegments, DExcExtractorListType.EListCodeSegments, EM.CodeSegmentsEntry); // We need to transition state to "stack data", but we must be sure not to throw away the state line we just encountered. listCodeSegments.AddExpression(DExcExtractorEntry.NewMatchSaveAndTransition(EM.StackDataEntry, TState.EStateStackData)); // Stack data // ========== DExcExtractorListStackData listStackData = new DExcExtractorListStackData(TState.EStateStackData, DExcExtractorListType.EListStackData); PrepareList(listStackData, EM.StackDataEntry); listStackData.AddExpression(DExcExtractorEntry.NewMatchSaveAndTransition(EM.LogStart, TState.EStateHeader)); // We want to observe the stack data as it arrives so that we can identify when all stack data has been supplied. listStackData.StackChanged += new DExcExtractorListStackData.StackDataChangeHandler(StackDataChanged); }
private void PrepareList(DExcExtractorList aList, params Regex[] aExpressions) { foreach (Regex exp in aExpressions) { DExcExtractorEntry entry = DExcExtractorEntry.NewMatchAndSave(exp); aList.AddExpression(entry); } // iLists.Add(aList.State, aList); iData.Add(aList); }
public DExcExtractorList this[DExcExtractorListType aType] { get { DExcExtractorList ret = null; // if (iLists.ContainsKey(aType)) { ret = iLists[aType]; } // return(ret); } }
public override string ToString() { StringBuilder ret = new StringBuilder(); // foreach (KeyValuePair <DExcExtractorListType, DExcExtractorList> kvp in iLists) { DExcExtractorList list = kvp.Value; string lines = list.ToString(); if (lines.Length > 0) { ret.AppendLine(lines); } } // return(ret.ToString()); }
public bool Offer(string aLine, long aLineNumber) { bool consumed = false; // Cache line number - we use this to update the data starting position // when the state is changed. iCurrentLineNumber = aLineNumber; // Get list for current state DExcExtractorList list = CurrentList; if (list != null) { consumed = list.Offer(aLine, aLineNumber, this); } return(consumed); }
public void Add(DExcExtractorList aList) { iLists.Add(aList.Type, aList); }