#parser #rfc3261 #quoted-string

quoted-string-parser

Quoted string parser for grammar defined in RFC3261

1 unstable release

0.1.0 May 6, 2022

#1662 in Text processing

Download history 1620/week @ 2024-05-21 1197/week @ 2024-05-28 1969/week @ 2024-06-04 920/week @ 2024-06-11 1585/week @ 2024-06-18 1753/week @ 2024-06-25 1909/week @ 2024-07-02 1761/week @ 2024-07-09 1978/week @ 2024-07-16 1868/week @ 2024-07-23 2566/week @ 2024-07-30 2531/week @ 2024-08-06 3449/week @ 2024-08-13 1628/week @ 2024-08-20 2286/week @ 2024-08-27 1834/week @ 2024-09-03

9,659 downloads per month
Used in 18 crates (via stun-rs)

MIT/Apache

16KB
174 lines

Docs

quoted-string-parser

This crates implements a parser for text that meets the grammar for "quoted-string" as described in SIP: Session Initiation Protocol. RFC3261

quoted-string  =  SWS DQUOTE *(qdtext / quoted-pair ) DQUOTE
qdtext         =  LWS / %x21 / %x23-5B / %x5D-7E / UTF8-NONASCII
quoted-pair    =  "\" (%x00-09 / %x0B-0C / %x0E-7F)
LWS            =  [*WSP CRLF] 1*WSP ; linear whitespace
SWS            =  [LWS] ; sep whitespace
UTF8-NONASCII  =  %xC0-DF 1UTF8-CONT
               /  %xE0-EF 2UTF8-CONT
               /  %xF0-F7 3UTF8-CONT
               /  %xF8-Fb 4UTF8-CONT
               /  %xFC-FD 5UTF8-CONT
UTF8-CONT      =  %x80-BF
DQUOTE         =  %x22      ; " (Double Quote)
CRLF           =  CR LF     ; Internet standard newline
CR             =  %x0D      ; carriage return
LF             =  %x0A      ; linefeed
WSP            =  SP / HTAB ; whitespace
SP             =  %x20
HTAB           =  %x09      ; horizontal tab

ParThe QuotedStringParser object provides an simple API to validate that input text meets the "quoted-string" grammar.

use quoted_string_parser::{QuotedStringParser, QuotedStringParseLevel};

// two qdtexts separated by a whitespace
assert!(QuotedStringParser::validate(
  QuotedStringParseLevel::QuotedString, "\"Hello world\""));

// one quoted-pair
assert!(QuotedStringParser::validate(
  QuotedStringParseLevel::QuotedString, "\"\\\u{7f}\""));

QuotedStringParser derives from Parser, if you need more control over the parser itself you can use any of the operations defined in the pest crate. Check the documentation for more information.

Documentation

https://docs.rs/quoted-string-parser

Contributing

Patches and feedback are welcome.

Donations

If you find this project helpful, you may consider making a donation:

Donate with Bitcoin Donate with Ethereum

License

This project is licensed under either of

say thanks

Dependencies

~2–2.8MB
~56K SLoC