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

Function parse_limit_statement

crates/gitql-parser/src/parser.rs:1190–1224  ·  view source on GitHub ↗
(
    tokens: &[Token],
    position: &mut usize,
)

Source from the content-addressed store, hash-verified

1188}
1189
1190fn parse_limit_statement(
1191 tokens: &[Token],
1192 position: &mut usize,
1193) -> Result<Statement, Box<Diagnostic>> {
1194 // Consume `LIMIT` keyword
1195 *position += 1;
1196
1197 if *position >= tokens.len() {
1198 return Err(Diagnostic::error("Expect number after `LIMIT` keyword")
1199 .with_location(calculate_safe_location(tokens, *position - 1))
1200 .as_boxed());
1201 }
1202
1203 match tokens[*position].kind {
1204 TokenKind::Integer(integer) => {
1205 // Consume Integer value
1206 *position += 1;
1207
1208 // Make sure limit value is always positive
1209 if integer < 0 {
1210 return Err(
1211 Diagnostic::error("Expect positive number after `LIMIT` keyword")
1212 .with_location(calculate_safe_location(tokens, *position - 1))
1213 .as_boxed(),
1214 );
1215 }
1216
1217 let count = integer as usize;
1218 Ok(Statement::Limit(LimitStatement { count }))
1219 }
1220 _ => Err(Diagnostic::error("Expect number after `LIMIT` keyword")
1221 .with_location(calculate_safe_location(tokens, *position - 1))
1222 .as_boxed()),
1223 }
1224}
1225
1226fn parse_offset_statement(
1227 context: &mut ParserContext,

Callers 1

parse_select_queryFunction · 0.85

Calls 4

calculate_safe_locationFunction · 0.85
as_boxedMethod · 0.80
with_locationMethod · 0.80
lenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…