MCPcopy Create free account
hub / github.com/archlinux/alpm / parser

Method parser

alpm-pkgbuild/src/bridge/parser.rs:349–371  ·  view source on GitHub ↗

Recognizes a [`Keyword`] in a variable declaration line in the output of the `alpm-pkgbuild-bridge` script. This parser is aware of its surrounding and consumes preceding spaces. # Errors Returns an error if no [`Keyword`] can be found in `input`.

(input: &mut &str)

Source from the content-addressed store, hash-verified

347 ///
348 /// Returns an error if no [`Keyword`] can be found in `input`.
349 pub(crate) fn parser(input: &mut &str) -> ModalResult<Keyword> {
350 let (keyword, suffix) = trace(
351 "keyword",
352 cut_err(preceded(
353 space1,
354 (
355 alphanumeric1,
356 opt(preceded('_', take_till(1.., |c| c == ' ' || c == '\n'))),
357 ),
358 ))
359 .context(StrContext::Label(
360 "keyword with potential architecture suffix, e.g. 'source_x86_64'",
361 ))
362 .context(StrContext::Expected(StrContextValue::Description(
363 "alphabetic keyword with potential architecture suffix, e.g. 'source_x86_64'",
364 ))),
365 )
366 .parse_next(input)?;
367 Ok(Keyword {
368 keyword: keyword.to_owned(),
369 suffix: suffix.map(ToString::to_string),
370 })
371 }
372}
373
374/// A type of variable found in the output of the `alpm-pkgbuild-bridge` script.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected