/// <summary> /// Tries to parse any of specified syntactic items. /// </summary> private bool ParseAnyInternal(SyntacticState state, params SyntacticItem[] parts) { int innerIndex = state.InnerPosition; int outerIndex = state.OuterPosition; foreach (SyntacticItem part in parts) { if (part.Parse(state)) { state.AddBack(Key, innerIndex, outerIndex); return(true); } } return(false); }
/// <summary> /// Execute parsing method checking research deep. /// </summary> private static bool Parse(ParseDelegate action, SyntacticState state, SyntacticItem[] args) { state.Deep++; #if DEBUG Debug.WriteLine(String.Empty); Debug.WriteLine(state.GetOuterDebug()); SyntacticItem debugItem = (SyntacticItem)action.Target; Debug.WriteLine("[{0}] ({1})", debugItem.Key, state.Deep); string debugMethod = action.Method.Name; debugMethod = debugMethod .Split( new[] { "Parse", "Internal", "<", ">" }, StringSplitOptions.RemoveEmptyEntries) .First() .ToUpperInvariant(); Debug.Write(debugMethod); Debug.Write(" ="); foreach (var arg in args.Where(arg => arg != null)) { Debug.Write(" | "); Debug.Write(arg.Key); } Debug.WriteLine(String.Empty); #endif if (state.Deep >= c_maxResearchDeep) { throw new InvalidOperationException( String.Format("Maximum research deep {0} has been reached.", c_maxResearchDeep)); } bool parsed = action.Invoke(state, args); state.Deep--; return(parsed); }
/// <summary> /// Tries to parse an entity from the specified syntactic machine state. /// In case of success returns true and advances parsing position. /// </summary> public override bool Parse(SyntacticState state) { if (state.IsEndOfData) { return(false); } LexicalEntry entry = state.GetInner(state.InnerPosition); if (entry.Key != m_item.Key) { return(false); } state.AddAbsolute( Key, state.InnerPosition + 1, entry.EndPosition); return(true); }
/// <summary> /// Tries to parse an entity from the specified syntactic machine state. /// In case of success returns true and advances parsing position. /// </summary> public override bool Parse(SyntacticState state) { if (state.IsEndOfData) { return(false); } LexicalEntry entry = state.GetInner(state.InnerPosition); string text = state.GetOuter(entry); if (text != m_text) { return(false); } state.AddAbsolute( Key, state.InnerPosition + 1, entry.EndPosition); return(true); }
/// <summary> /// Tries to parse an entity from the specified syntactic machine state. /// In case of success returns true and advances parsing position. /// </summary> public abstract bool Parse(SyntacticState state);