Title: Theory / Unimportant / CS / Programming / Rust / Library / Nom
Tags: automatedNewLineAfterCommaSpace constant seen_description
On every note of this deck, unless a note says otherwise:
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md

Name: Nom
Definition: Rust parser library
Page: https://docs.rs/nom/6.0.1/nom/
Context: Rust

Name: Parser
Definition: A function which, for an input type I, an output type O and an optional error type E, will have the following signature:
(input: I) -> IResult<I, O, E>; or (input: I) -> IResult<I, O>;
Page: https://docs.rs/nom/6.0.1/nom/
Context: Nom, Rust

Typ: IResult<I,O,E>
Page: https://docs.rs/nom/6.0.1/nom/
Language: Nom, Rust
Value: Ok((I,O)), with remaining of string and matched
Value2: Incomplete(Needed), stating more chars are required, potentially how many
Value3: Err(E)

Instruction: char!('a')
Language: Nom parser, Rust
Returns: Matches the one character 'a' (works with non ASCII chars too)

Instruction: is_a!("foo")
Language: Nom parser, Rust
Returns: Matches a sequences of the letters of "foo"

Instruction: is_not!("foo")
Language: Nom parser, Rust
Returns: Matches a sequences of the letters not belonging to "foo"

Instruction: one_of!("foo")
Language: Nom parser, Rust
Returns: Matches one of the character of foo

Instruction: none_of!("foo")
Language: Nom parser, Rust
Returns: Matches anything but the characters from foo

Instruction: tag!("foo")
Language: Nom parser, Rust
Returns: Matches the exact word foo

Instruction: tag_no_case!("foo")
Language: Nom parser, Rust
Returns: Matches the exact word foo, ignoring case

Instruction: take_while!(pred)
Language: Nom parser, Rust
Returns: The longest list of bytes satisfying pred

Instruction: take_while1!(pred)
Language: Nom parser, Rust
Returns: The longest list of bytes satisfying pred, at least 1

Instruction: take_till!(pred)
Language: Nom parser, Rust
Returns: The longest list of bytes not satisfying pred

Instruction: take_till1!(pred)
Language: Nom parser, Rust
Returns: The longest list of bytes not satisfying pred, at least 1

Instruction: take_until("foo")
Language: Nom parser, Rust
Returns: Take the longest list of bytes until foo is found

Instruction: alt!(
  parser_1,
  ...,
  parser_n
)
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Language: Nom parser,
  Rust
Returns: Return the result of the first succesful parser between all of parser_i

Instruction: switch!(
  parser_if,
  parser_then| parser_else
)
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Language: Nom parser,
  Rust
Returns: If parser_if success, then parser_then result, else parser_else's result

Instruction: permutation!(
  parser_1,
  ..., parser_n
)
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Language: Nom parser,
  Rust
Returns: Succeeds when all the child parser have succeeded, whatever the order. Return the tuple in same order as arguments

Instruction: delimited!(
  parser_open,
  parser,
  parser_close
)
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Language: Nom parser,
  Rust
Returns: Match the sequence of parser_open, parser and parser_close and return the result of parser

Instruction: preceded!(
  parser_open,
  parser
)
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Effect: match parser_open and parser and return parser (?)
Language: Nom parser,
  Rust

Instruction: terminated!(parser, parser_close)
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Effect: match parser and parser_close
Language: Nom parser, Rust
Returns: The result of parser

Instruction: pair!(parser_left, parser_right)
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Language: Nom parser, Rust
Returns: The pair of result applied by matching parser_left and then parser_right

Instruction: pair!(
  parser_left,
  parser_separator, parser_right
)
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Effect: match parser_left, followed by parser_separator and parser_right
Language: Nom parser,
  Rust
Returns: The pair of result applied by matching parser_left and then parser_right

Instruction: tuple!(
  parser_1,
  ..., parser_n
)
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Effect: match the sequence of parser_i in this order and return this result
Language: Nom parser,
  Rust

Instruction: do_parse!(
  parser_1,
  ..., parser_n
)
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Effect: Omitted
Language: Nom parser,
  Rust

Instruction: count!(
  parser,
  n
)
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Language: Nom parser,
  Rust
Returns: A vector of result of n successive parser

Instruction: many_m_n!(
  parser,
  m,
  n
)
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Language: Nom parser,
  Rust
Returns: A vector of result of applying parser between m and n time

Instruction: many_till!(
  parser_1,
  parser_2
)
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Language: Nom parser,
  Rust
Returns: A pair, with vector applying parser_1 until parser_2 is valid, and parser_2 result

Instruction: separated_list!(
  parser_separator,
  parser
)
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Language: Nom parser,
  Rust
Returns: A vector of result of parser, separated by parser_separator

Instruction: fold_many?!
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Language: Nom parser, Rust
Returns: Omitted

Instruction: length_count!(
  parser_count,
  parser
)
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Language: Nom parser,
  Rust
Returns: Vector of applying parser as many time as parsed by parser_count first

Instruction: eof!
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Language: Nom parser, Rust
Returns: Returns its input if it is at the end of the input data

Instruction: complete!(Incomplete(e))
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Language: Nom parser, Rust
Returns: Error(e)

Instruction: cond!
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Returns: Conditional combinator. Wraps another parser and calls it if the condition is met

Instruction: map_opt!
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Returns: Maps a function returning an Option on the output of a parser

Instruction: map_res!
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Returns: Maps a function returning a Result on the output of a parser

Instruction: not!
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Returns: Returns a result only if the embedded parser returns Error or Incomplete. Does not consume the input

Instruction: opt!
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Returns: Make the underlying parser optional

Instruction: opt_res!
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Returns: Make the underlying parser optional

Instruction: parse_to!
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Returns: Uses the parse method from std::str::FromStr to convert the current input to the specified type

Instruction: peek!
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Returns: Returns a result without consuming the input

Instruction: recognize!
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Returns: If the child parser was successful, return the consumed input as the produced value

Instruction: consumed()
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Returns: If the child parser was successful, return a tuple of the consumed input and the produced output.

Instruction: return_error!
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Returns: Prevents backtracking if the child parser fails

Instruction: tap!
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Returns: Allows access to the parser's result without affecting it

Instruction: verify!
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Returns: Returns the result of the child parser if it satisfies a verification function

Instruction: add_return_error!
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Returns: Add an error if the child parser fails

Instruction: dbg!
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Returns: Prints a message if the parser fails

Instruction: dbg_dmp!
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Returns: Prints a message and the input if the parser fails

Instruction: error_node_position!
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Returns: Creates a parse error from a nom::ErrorKind, the position in the input and the next error in the parsing tree. If the verbose-errors feature is not activated, it defaults to only the error code

Instruction: error_position!
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Returns: Creates a parse error from a nom::ErrorKind and the position in the input. If the verbose-errors feature is not activated, it defaults to only the error code

Instruction: fix_error!
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Returns: Translate parser result from IResult to IResult with a custom type

Instruction: escaped!
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Returns: Matches a byte string with escaped characters

Instruction: escaped_transform!
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Returns: Matches a byte string with escaped characters, and returns a new string with the escaped characters replaced

Instruction: length_data!
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Returns: Gets a number from the first parser, then takes a subslice of the input of that size, and returns that subslice

Instruction: length_bytes!
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Returns: Alias for length_data

Instruction: length_value!
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Returns: Gets a number from the first parser, takes a subslice of the input of that size, then applies the second parser on that subslice. If the second parser returns Incomplete, length_value! will return an error

Instruction: bits!
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Returns: Transforms the current input type (byte slice &[u8]) to a bit stream on which bit specific parsers and more general combinators can be applied

Instruction: bytes!
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Returns: Transforms its bits stream input back into a byte slice for the underlying parser

Instruction: tag_bits!
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Returns: Matches an integer pattern to a bitstream. The number of bits of the input to compare must be specified

Instruction: take_bits!
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Returns: Generates a parser consuming the specified number of bits

Instruction: call!
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Returns: Used to wrap common expressions and function as macros

Instruction: method!
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Returns: Makes a method from a parser combination

Instruction: named!
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Returns: Makes a function from a parser combination

Instruction: named_args!
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Returns: Makes a function from a parser combination with arguments

Instruction: named_attr!
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Returns: Makes a function from a parser combination, with attributes

Instruction: try_parse!
Page: https://github.com/Geal/nom/blob/master/doc/choosing_a_combinator.md
Returns: A bit like std::try!, this macro will return the remaining input and parsed value if the child parser returned Ok, and will do an early return for Error and Incomplete. This can provide more flexibility than do_parse! if needed

Constant: success
Meaning: Returns a value without consuming any input, always succeeds

Constant: double
Meaning: Recognizes floating point number in a byte string and returns a f64

Constant: hex_u32
Meaning: Recognizes a hex-encoded integer

Constant: line_ending
Meaning: Recognizes an end of line (both \n and \r\n)

Constant: multispace
Meaning: Recognizes one or more spaces, tabs, carriage returns and line feeds

Constant: newline
Meaning: Matches a newline character \n

Constant: non_empty
Meaning: Recognizes non empty buffers

Constant: rest
Meaning: Return the remaining input

Constant: tab
Meaning: Matches a tab character \t