Skip to main content

linkrs_query/parser/parsing/
ddl_parser.rs

1mod alter_parser;
2mod create_parser;
3mod describe_parser;
4mod drop_parser;
5mod helpers;
6
7use crate::parser::core::error::ParseError;
8use crate::parser::parsing::parse_context::ParseContext;
9use crate::parser::TokenKind;
10
11pub struct DdlParser;
12
13impl DdlParser {
14    pub fn new() -> Self {
15        Self
16    }
17}
18
19/// Consume either the `SPACE` token or the `GRAPH` keyword (namespace
20/// alias shared by CREATE, USE and DROP). Returns `Ok(true)` when either
21/// was matched and consumed.
22pub(crate) fn consume_space_or_graph(ctx: &mut ParseContext) -> Result<bool, ParseError> {
23    if ctx.match_token(TokenKind::Space) {
24        return Ok(true);
25    }
26    if ctx.check_keyword("GRAPH") {
27        ctx.consume_keyword("GRAPH")?;
28        return Ok(true);
29    }
30    Ok(false)
31}
32
33impl Default for DdlParser {
34    fn default() -> Self {
35        Self::new()
36    }
37}