public static bool TryParseNode(Genero4glParser parser, out CreateStatement node, IModuleResult containingModule) { node = null; bool result = true; if (parser.PeekToken(TokenKind.CreateKeyword)) { parser.NextToken(); switch (parser.PeekToken().Kind) { case TokenKind.SequenceKeyword: CreateSequenceStatement sequenceNode; result = CreateSequenceStatement.TryParseNode(parser, out sequenceNode); node = sequenceNode; break; case TokenKind.TableKeyword: case TokenKind.TempKeyword: CreateTableStatement tableNode; result = CreateTableStatement.TryParseNode(parser, out tableNode, containingModule); node = tableNode; break; default: result = false; break; } } return(result); }
internal static bool TryParseNode(Genero4glParser parser, out CreateSequenceStatement node) { node = null; bool result = false; if (parser.PeekToken(TokenKind.SequenceKeyword)) { result = true; node = new CreateSequenceStatement(); node.StartIndex = parser.Token.Span.Start; // want to get the start of the create token parser.NextToken(); if (parser.PeekToken(TokenKind.IfKeyword)) { parser.NextToken(); if (parser.PeekToken(TokenKind.NotKeyword)) { parser.NextToken(); if (parser.PeekToken(TokenKind.ExistsKeyword)) { parser.NextToken(); } else { parser.ReportSyntaxError("Expecting \"exists\" keyword in create sequence statement."); } } else { parser.ReportSyntaxError("Expecting \"not\" keyword in create sequence statement."); } } FglNameExpression nameExpr; if (FglNameExpression.TryParseNode(parser, out nameExpr)) { node.SequenceName = nameExpr; } else { parser.ReportSyntaxError("Invalid name found for create sequence statement."); } // TODO: finish getting the modifiers } return(result); }