From 82ecd16f20f1a9461440c10107855d984125778e Mon Sep 17 00:00:00 2001 From: Eric Date: Mon, 4 Apr 2022 15:15:56 +0800 Subject: [PATCH] parser support differentiate newline and space --- sv-parser-parser/src/utils.rs | 5 ++++- sv-parser-syntaxtree/src/special_node.rs | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/sv-parser-parser/src/utils.rs b/sv-parser-parser/src/utils.rs index c94365e..902777c 100644 --- a/sv-parser-parser/src/utils.rs +++ b/sv-parser-parser/src/utils.rs @@ -314,9 +314,12 @@ pub(crate) fn white_space(s: Span) -> IResult { })(s) } else { alt(( - map(multispace1, |x: Span| { + map(space1, |x: Span| { WhiteSpace::Space(Box::new(into_locate(x))) }), + map(multispace1, |x: Span| { + WhiteSpace::Newline(Box::new(into_locate(x))) + }), map(preceded(peek(char('/')), comment), |x| { WhiteSpace::Comment(Box::new(x)) }), diff --git a/sv-parser-syntaxtree/src/special_node.rs b/sv-parser-syntaxtree/src/special_node.rs index 753824d..fd1b528 100644 --- a/sv-parser-syntaxtree/src/special_node.rs +++ b/sv-parser-syntaxtree/src/special_node.rs @@ -14,6 +14,7 @@ pub struct Keyword { #[derive(Clone, Debug, PartialEq, Node)] pub enum WhiteSpace { + Newline(Box), Space(Box), Comment(Box), CompilerDirective(Box),