2024年12月27日

就是说可以把多个基础解析器组装成一个组合器,然后还可以基于组合器再进行组合?

摘要: UUUUUUUUUUUUUUUUUUUUUUUUUU 是的,正是这样!在 nom 中,解析器组合器(parser combinators)让你能够将多个基础解析器组合在一起,构建更复杂的解析器。这种组合方式具有非常高的灵活性和可复用性。 组合器的基本理念 基础解析器:这些是最简单的解析器,负责匹配输 阅读全文

posted @ 2024-12-27 18:57 及途又八 阅读(44) 评论(0) 推荐(0)

给我讲讲nom中的基本概念吧

摘要: UUUUUUUUUUUUUUUUU 在 nom 中,基本概念围绕着 解析器组合器(parser combinators)的理念。解析器组合器是一种方法,通过将简单的解析器组合在一起构建复杂的解析器。nom 提供了丰富的组合器和基础工具,使得解析过程更加灵活和高效。 1. IResult nom 中的 阅读全文

posted @ 2024-12-27 18:51 及途又八 阅读(114) 评论(0) 推荐(0)

nom::sequence::preceded Matches an object from the first parser and discards it, then gets an object from the second parser. 上面是rust nom官网对于preceded的解释

摘要: nom::sequence::preceded Matches an object from the first parser and discards it, then gets an object from the second parser. 上面是rust nom官网对于preceded的解 阅读全文

posted @ 2024-12-27 16:44 及途又八 阅读(19) 评论(0) 推荐(0)

完成这个函数,解析带符号或不带符号的整形

摘要: fn integer64(input: &str) -> IResult<&str, Token> { // map(digit1, |s: &str| Token::Number(s.parse().unwrap()))(input) } 完成这个函数,解析带符号或不带符号的整形 UUUUUUUU 阅读全文

posted @ 2024-12-27 14:17 及途又八 阅读(23) 评论(0) 推荐(0)

修改上面函数,忽略大小写

摘要: fn keyword(input: &str) -> IResult<&str, Token> { alt(( map(tag("SELECT"), |_| Token::Keyword("SELECT".to_string())), map(tag("FROM"), |_| Token::Keyw 阅读全文

posted @ 2024-12-27 12:31 及途又八 阅读(10) 评论(0) 推荐(0)

导航