aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLefteris Karapetsas <lefteris@refu.co>2014-12-18 20:27:25 +0800
committerLefteris Karapetsas <lefteris@refu.co>2014-12-18 22:03:45 +0800
commit00d6c1ac347b4f5e6d4b3883da862d6fafe11f4b (patch)
treea51b3fc5b9486ecac5080287d9c88e668563adac
parent734a609d6981c308df32542fa3a68fe893bfe667 (diff)
downloaddexon-solidity-00d6c1ac347b4f5e6d4b3883da862d6fafe11f4b.tar.gz
dexon-solidity-00d6c1ac347b4f5e6d4b3883da862d6fafe11f4b.tar.zst
dexon-solidity-00d6c1ac347b4f5e6d4b3883da862d6fafe11f4b.zip
Scanner properly scans multiline natspec comments
- Single and multiline natspect comments get the initial whitespace skipped now - Some rules introduced for the multiline comments. If first line is empty then no newline is added to the literal. Same thing with the last line. Finally in all lines initial '*' are skipped
-rw-r--r--solidityScanner.cpp25
1 files changed, 22 insertions, 3 deletions
diff --git a/solidityScanner.cpp b/solidityScanner.cpp
index 2b8c7c45..159e5305 100644
--- a/solidityScanner.cpp
+++ b/solidityScanner.cpp
@@ -157,14 +157,14 @@ BOOST_AUTO_TEST_CASE(documentation_comments_parsed_begin)
{
Scanner scanner(CharStream("/// Send $(value / 1000) chocolates to the user"));
BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::EOS);
- BOOST_CHECK_EQUAL(scanner.getCurrentCommentLiteral(), " Send $(value / 1000) chocolates to the user");
+ BOOST_CHECK_EQUAL(scanner.getCurrentCommentLiteral(), "Send $(value / 1000) chocolates to the user");
}
BOOST_AUTO_TEST_CASE(multiline_documentation_comments_parsed_begin)
{
Scanner scanner(CharStream("/** Send $(value / 1000) chocolates to the user*/"));
BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::EOS);
- BOOST_CHECK_EQUAL(scanner.getCurrentCommentLiteral(), " Send $(value / 1000) chocolates to the user");
+ BOOST_CHECK_EQUAL(scanner.getCurrentCommentLiteral(), "Send $(value / 1000) chocolates to the user");
}
BOOST_AUTO_TEST_CASE(documentation_comments_parsed)
@@ -174,7 +174,19 @@ BOOST_AUTO_TEST_CASE(documentation_comments_parsed)
BOOST_CHECK_EQUAL(scanner.next(), Token::IDENTIFIER);
BOOST_CHECK_EQUAL(scanner.next(), Token::IDENTIFIER);
BOOST_CHECK_EQUAL(scanner.next(), Token::EOS);
- BOOST_CHECK_EQUAL(scanner.getCurrentCommentLiteral(), " Send $(value / 1000) chocolates to the user");
+ BOOST_CHECK_EQUAL(scanner.getCurrentCommentLiteral(), "Send $(value / 1000) chocolates to the user");
+}
+
+BOOST_AUTO_TEST_CASE(multiline_documentation_comments_parsed)
+{
+ Scanner scanner(CharStream("some other tokens /**\n"
+ "* Send $(value / 1000) chocolates to the user\n"
+ "*/"));
+ BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::IDENTIFIER);
+ BOOST_CHECK_EQUAL(scanner.next(), Token::IDENTIFIER);
+ BOOST_CHECK_EQUAL(scanner.next(), Token::IDENTIFIER);
+ BOOST_CHECK_EQUAL(scanner.next(), Token::EOS);
+ BOOST_CHECK_EQUAL(scanner.getCurrentCommentLiteral(), "Send $(value / 1000) chocolates to the user");
}
BOOST_AUTO_TEST_CASE(comment_before_eos)
@@ -191,6 +203,13 @@ BOOST_AUTO_TEST_CASE(documentation_comment_before_eos)
BOOST_CHECK_EQUAL(scanner.getCurrentCommentLiteral(), "");
}
+BOOST_AUTO_TEST_CASE(empty_multiline_documentation_comment_before_eos)
+{
+ Scanner scanner(CharStream("/***/"));
+ BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::EOS);
+ BOOST_CHECK_EQUAL(scanner.getCurrentCommentLiteral(), "");
+}
+
BOOST_AUTO_TEST_CASE(comments_mixed_in_sequence)
{
Scanner scanner(CharStream("hello_world ///documentation comment \n"