private static bool TryGetConstructStatement(Genero4glParser parser, out ConstructDialogStatement node, bool returnFalseInsteadOfErrors = false) { bool result = false; node = null; ConstructDialogStatement constStmt; if ((result = ConstructDialogStatement.TryParseNode(parser, out constStmt, returnFalseInsteadOfErrors))) { node = constStmt; } return(result); }
public static bool TryParseNode(Genero4glParser parser, out ConstructDialogStatement node, bool returnFalseInsteadOfErrors = false) { node = new ConstructDialogStatement(); bool result = true; switch (parser.PeekToken().Kind) { case TokenKind.ContinueKeyword: case TokenKind.ExitKeyword: { if (parser.PeekToken(TokenKind.ConstructKeyword, 2)) { parser.NextToken(); node.StartIndex = parser.Token.Span.Start; parser.NextToken(); } else { result = false; } break; } case TokenKind.NextKeyword: { parser.NextToken(); node.StartIndex = parser.Token.Span.Start; if (parser.PeekToken(TokenKind.FieldKeyword)) { parser.NextToken(); switch (parser.PeekToken().Kind) { case TokenKind.NextKeyword: case TokenKind.PreviousKeyword: parser.NextToken(); break; default: { // get the field-spec FglNameExpression fieldSpec; if (FglNameExpression.TryParseNode(parser, out fieldSpec)) { node.FieldSpec = fieldSpec; } else { parser.ReportSyntaxError("Invalid field-spec found in construct statement."); } break; } } } else { if (!returnFalseInsteadOfErrors) { parser.ReportSyntaxError("Expecting \"field\" keyword in construct statement."); } else { return(false); } } break; } default: { result = false; break; } } if (result) { node.EndIndex = parser.Token.Span.End; } return(result); }