From 403b5245290c49c2e909d5057ab250cebbd1de74 Mon Sep 17 00:00:00 2001 From: anweiss <2326106+anweiss@users.noreply.github.com> Date: Fri, 11 Dec 2020 16:08:13 -0500 Subject: [PATCH 1/3] fix newline parsing bug --- src/parser.rs | 82 +++++++++++++++++++++++++++------------------------ 1 file changed, 43 insertions(+), 39 deletions(-) diff --git a/src/parser.rs b/src/parser.rs index a9a7e4af..ed157932 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -1282,55 +1282,59 @@ where ))), } } - _ => match self.cur_token.in_standard_prelude() { - Some(s) => { - let ident = self.identifier_from_ident_token((s, None)); - self.parser_position.range = self.lexer_position.range; - self.parser_position.line = self.lexer_position.line; - - Ok(Type2::Typename { - ident, - generic_args: None, - span: ( - self.parser_position.range.0, - self.parser_position.range.1, - self.parser_position.line, - ), - }) - } - None => { - self.parser_position.line = self.lexer_position.line; - self.parser_position.range = self.lexer_position.range; + _ => { + self.collect_comments()?; - if self.cur_token_is(Token::COLON) || self.cur_token_is(Token::ARROWMAP) { - self.errors.push(ParserError { - position: self.parser_position, - msg: MissingGroupEntryMemberKey.into(), - }); + match self.cur_token.in_standard_prelude() { + Some(s) => { + let ident = self.identifier_from_ident_token((s, None)); + self.parser_position.range = self.lexer_position.range; + self.parser_position.line = self.lexer_position.line; - return Err(Error::PARSER); + Ok(Type2::Typename { + ident, + generic_args: None, + span: ( + self.parser_position.range.0, + self.parser_position.range.1, + self.parser_position.line, + ), + }) } + None => { + self.parser_position.line = self.lexer_position.line; + self.parser_position.range = self.lexer_position.range; + + if self.cur_token_is(Token::COLON) || self.cur_token_is(Token::ARROWMAP) { + self.errors.push(ParserError { + position: self.parser_position, + msg: MissingGroupEntryMemberKey.into(), + }); + + return Err(Error::PARSER); + } + + if self.cur_token_is(Token::RBRACE) + || self.cur_token_is(Token::RBRACKET) + || self.cur_token_is(Token::RPAREN) + { + self.errors.push(ParserError { + position: self.parser_position, + msg: MissingGroupEntry.into(), + }); + + return Err(Error::PARSER); + } - if self.cur_token_is(Token::RBRACE) - || self.cur_token_is(Token::RBRACKET) - || self.cur_token_is(Token::RPAREN) - { self.errors.push(ParserError { position: self.parser_position, - msg: MissingGroupEntry.into(), + msg: InvalidGroupEntrySyntax.into(), }); - return Err(Error::PARSER); + Err(Error::PARSER) } - - self.errors.push(ParserError { - position: self.parser_position, - msg: InvalidGroupEntrySyntax.into(), - }); - - Err(Error::PARSER) } - }, + } }; self.parser_position.range.1 = self.lexer_position.range.1; From 24c5bb0f894a1cc4e74ccbd6151680133dd815d5 Mon Sep 17 00:00:00 2001 From: anweiss <2326106+anweiss@users.noreply.github.com> Date: Mon, 25 Jan 2021 12:38:11 -0500 Subject: [PATCH 2/3] fix clippy lints --- src/parser.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/parser.rs b/src/parser.rs index ed157932..db245d1d 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -2466,9 +2466,7 @@ pub fn cddl_from_str<'a>( pub fn cddl_from_str(input: &str) -> result::Result { match Parser::new(Lexer::new(input).iter(), input) { Ok(mut p) => match p.parse_cddl() { - Ok(c) => JsValue::from_serde(&c) - .map_err(|e| JsValue::from(e.to_string())) - .map(|c| c), + Ok(c) => JsValue::from_serde(&c).map_err(|e| JsValue::from(e.to_string())), Err(Error::PARSER) => { if !p.errors.is_empty() { return Err(JsValue::from_serde(&p.errors).map_err(|e| JsValue::from(e.to_string()))?); From e731ce8c6a4bd21e00e0b68d327f29b4ff1cb11f Mon Sep 17 00:00:00 2001 From: anweiss <2326106+anweiss@users.noreply.github.com> Date: Mon, 25 Jan 2021 12:44:16 -0500 Subject: [PATCH 3/3] update workflow --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 81aa0e72..8985191f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -157,12 +157,14 @@ jobs: components: rustfmt, clippy - name: cargo +${{ matrix.rust_toolchain }} fmt + if: ${{ always() }} uses: actions-rs/cargo@v1 with: command: fmt args: --all -- --check - name: cargo +${{ matrix.rust_toolchain }} clippy + if: ${{ always() }} uses: actions-rs/cargo@v1 with: command: clippy @@ -188,6 +190,7 @@ jobs: components: rustfmt, clippy - name: cargo +${{ matrix.rust_toolchain }} clippy + if: ${{ always() }} uses: actions-rs/cargo@v1 with: command: clippy