private static SyntaxNode FactoryCreateCompoundJoin(ParsingContext xoContext) { // Break early if we got 1 join keyword if (xoContext.List.Peek().ExpectedType == SyntaxKind.JoinKeyword) { // All Join nodes on their own become Inner joins SyntaxNode oJoinNode = new SyntaxNode( xoContext.List.Peek(), NodeStrategyFactory.FactoryCreateStrategy(xoContext.List.Pop().ExpectedType), 2); oJoinNode.ExpectedType = SyntaxKind.InnerJoinKeyword; return(oJoinNode); } // Create the Join Node SyntaxNode oTemp = new SyntaxNode(xoContext.List.Peek(), NodeStrategyFactory.FactoryCreateStrategy(xoContext.List.Pop().ExpectedType)); // If the next node is actually an OUTER keyword if (xoContext.List.Peek().ExpectedType == SyntaxKind.OuterKeyword) { // Construct a proper Join keyword with the type declared oTemp.RawSQLText += " " + xoContext.List.Pop().RawSQLText; // add the text (OUTER) } // If the next node is actually a Join if (xoContext.List.Peek().ExpectedType == SyntaxKind.JoinKeyword) { // Construct a proper Join keyword with the type declared oTemp.RawSQLText += " " + xoContext.List.Pop().RawSQLText; // add the text (JOIN) } else { // Add an error oTemp.Comments.Add(ErrorMessageLibrary.GetErrorMessage(8000, xoContext.List.Pop().RawSQLText, "JOIN")); } // Return the Join node return(oTemp); }
public static SyntaxTrivia ScanMultiLineComment(SlidingTextWindow TextWindow) { // Check next char char xcNextChar = TextWindow.PeekCharacter(); // If it is /* if (xcNextChar == '/' && TextWindow.PeekCharacter(1) == '*') { // Ignore comment sections TextWindow.SkipAhead(2); Boolean bIsCommentTerminated = false; String sCommentLine = String.Empty; // Iterate indefinitely until we reach the end for (int iIndex = 0; TextWindow.Position + iIndex < TextWindow.Count; iIndex++) { // Terminating Case (find * and then /) if (TextWindow.PeekCharacter(iIndex) == '*' && TextWindow.PeekCharacter(iIndex + 1) == '/') { bIsCommentTerminated = true; break; } // Keep adding characters to our intermediate var sCommentLine += TextWindow.PeekCharacter(iIndex); } // Just advance the length of the text (we can't fix peoples comments 100% // of the time) TextWindow.SkipAhead(sCommentLine.Length); // If our comment was terminated properly if (bIsCommentTerminated) { // Ignore the */ TextWindow.SkipAhead(2); return(SyntaxFactory.MultiLineComment(sCommentLine)); } // Not terminated properly.. (hardest case) // If we reach the end of the window its either an EOF comment (which is unlikely) // or it is an unterminated comment else { // Intermediate Var (Add all the text as a comment) SyntaxTrivia oCommentNode = SyntaxFactory.MultiLineComment(sCommentLine); oCommentNode.Comments.Add(ErrorMessageLibrary.GetErrorMessage(8002, "Multi Line Comment")); // return the comment node with everything in comments return(oCommentNode); } } // This token should not be here (there is something wrong) // Intermediate Var (Add all the text as a comment) SyntaxTrivia oErraneousToken = new SyntaxTrivia( SyntaxKind.UnknownNode, // Unknown Convert.ToString(TextWindow.PeekCharacter())); // Get the character out of the stream // oErraneousToken.Comments.Add(ErrorMessageLibrary.GetErrorMessage(8001, Convert.ToString(TextWindow.PopCharacter()))); // return the comment node with everything in comments return(oErraneousToken); }