MCPcopy Create free account
hub / github.com/AmrDeveloper/GQL / parse_window_named_over_clause

Function parse_window_named_over_clause

crates/gitql-parser/src/parser.rs:1251–1299  ·  view source on GitHub ↗
(
    context: &mut ParserContext,
    env: &mut Environment,
    tokens: &[Token],
    position: &mut usize,
)

Source from the content-addressed store, hash-verified

1249}
1250
1251fn parse_window_named_over_clause(
1252 context: &mut ParserContext,
1253 env: &mut Environment,
1254 tokens: &[Token],
1255 position: &mut usize,
1256) -> Result<(), Box<Diagnostic>> {
1257 consume_token_or_error(
1258 tokens,
1259 position,
1260 TokenKind::Window,
1261 "Expect `WINDOW` keyword.",
1262 )?;
1263
1264 let window_name_token = consume_conditional_token_or_errors(
1265 tokens,
1266 position,
1267 |t| matches!(t.kind, TokenKind::Symbol(_)),
1268 "Expect `Identifier` as window over clauses name.",
1269 )?;
1270
1271 let location = window_name_token.location;
1272 let window_name = window_name_token.to_string();
1273
1274 consume_token_or_error(
1275 tokens,
1276 position,
1277 TokenKind::As,
1278 "Expect `AS` keyword after window name.",
1279 )?;
1280
1281 let over_clauses = parse_over_window_definition(context, env, tokens, position)?;
1282
1283 // Make sure each window clauses has unique name
1284 if context.named_window_clauses.contains_key(&window_name) {
1285 return Err(Diagnostic::error(&format!(
1286 "There is already defined window clauses with name {window_name}"
1287 ))
1288 .add_note("Window over clauses names must be unique from each other")
1289 .with_location(location)
1290 .as_boxed());
1291 }
1292
1293 // Register window over clauses with name
1294 context
1295 .named_window_clauses
1296 .insert(window_name, over_clauses);
1297
1298 Ok(())
1299}
1300
1301pub(crate) fn parse_expression(
1302 context: &mut ParserContext,

Callers 1

parse_select_queryFunction · 0.85

Calls 6

consume_token_or_errorFunction · 0.85
as_boxedMethod · 0.80
with_locationMethod · 0.80
add_noteMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…