public Transaction(ParserState state) { this.state = state; index = state.Index; indentIndex = state.IndentIndex; userState = state.UserState?.Clone(); }
/// <summary> /// Creates a copy of a parser state. /// </summary> /// <param name="other">The other state to make a copy of.</param> public ParserState(ParserState other) { Source = other.Source; TabSize = other.TabSize; Index = other.Index; IndentIndex = other.IndentIndex; UserState = other.UserState?.Clone(); }
/// <summary> /// Creates a new parser state. /// </summary> /// <param name="source"> /// The contents of the source to parse. /// </param> /// <param name="state"> /// Some arbitrary user state that can accompany a parsing operation. /// </param> public ParserState (string source, int tabSize, ParserUserState userState = null) { Source = source; TabSize = tabSize; Index = 0; IndentIndex = 0; UserState = userState; }
/// <summary> /// Updates the transaction to use the current index when rolling back. /// </summary> public void CommitIndex() { index = state.Index; userState = state.UserState; }