public override bool Equals(object obj) { if (obj == null || !(obj is GrammarRule otherRule)) { return(false); } return(ResultToken.Equals(otherRule.ResultToken) && SourceTokens.SequenceEqual(otherRule.SourceTokens)); }
/// <summary> /// Always use this method add new token to this line (never call directly Tokens.Add) /// </summary> internal void AddToken(Token token) { // Identify pseudo-text tokens : could be necessary to filter them from "real" source text tokens if (ScanState.InsidePseudoText && token.TokenType != TokenType.PseudoTextDelimiter) { token.IsPseudoText = true; } // Register new token in list SourceTokens.Add(token); // Register scan state before COPY and EXECL SQL INCLUDE tokens // (necessary to scan properly the imported document) if (token.TokenType == TokenType.COPY || token.TokenType == TokenType.EXEC) { if (ScanStateBeforeCOPYToken == null) { ScanStateBeforeCOPYToken = new Dictionary <Token, MultilineScanState>(); } ScanStateBeforeCOPYToken[token] = ScanState.Clone(); } // Advance MultilineScanState if (Type != CobolTextLineType.Blank) // see p54 : for continuation, blank lines are treated like comment lines { ScanState.AdvanceToNextStateAndAdjustTokenProperties(token); } // Register multiline continuation tokens if (token.IsContinuationToken) { ContinuationToken continuationToken = (ContinuationToken)token; HasTokenContinuationFromPreviousLine = HasTokenContinuationFromPreviousLine || continuationToken.IsContinuationFromPreviousLine; HasTokenContinuedOnNextLine = HasTokenContinuedOnNextLine || continuationToken.IsContinuedOnNextLine; } }
/// <summary> /// In case a continuation of the last token of this line is discovered on the next line, /// remove all diagnostics specifically attached to this incomplete token /// </summary> internal void RemoveDiagnosticsForLastSourceToken() { Token lastToken = SourceTokens.Last(); RemoveDiagnosticsForToken(lastToken); }