1个不稳定版本
0.1.0 | 2022年5月6日 |
---|
1585 在 文本处理
6,212 每月下载量
在 16 个Crate中使用 (通过 stun-rs)
16KB
174 代码行
quoted-string-parser
这个crate实现了一个解析器,用于解析符合SIP:会话初始化协议中描述的“引用字符串”语法的文本。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
QuotedStringParser对象提供了一个简单的API来验证输入文本是否符合“引用字符串”语法。
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继承自Parser,如果您需要更多控制解析器本身,您可以使用pest crate中定义的任何操作。请查阅文档以获取更多信息。
文档
https://docs.rs/quoted-string-parser
贡献
欢迎提交补丁和反馈。
捐赠
如果您觉得这个项目有帮助,您可以考虑进行捐赠
许可证
本项目许可协议为以下之一:
- Apache License,版本2.0,(LICENSE-APACHE 或 https://apache.ac.cn/licenses/LICENSE-2.0)
- MIT许可证 (LICENSE-MIT 或 https://opensource.org/licenses/MIT),任选其一。
依赖项
~2.1–2.9MB
~57K SLoC