summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authorTakeshi Abe <tabe@fixedpoint.jp>2017-07-13 19:07:36 +0900
committerTakeshi Abe <tabe@fixedpoint.jp>2017-07-14 02:52:54 +0200
commitb9bda1d7916c5474aab89116757fcb7e799458b2 (patch)
tree7bba0353f35a7d09642b77cd73b9482e127b2128 /basic
parenta2e670df4efb219a1f92946d7a2887bdd0f88f5d (diff)
tdf#103104 Allow line-continuation followed by a dot in BASIC
as in VBA-compatibility mode. Change-Id: If263183fc1fa5742235213a8617fdf412d2a245e Reviewed-on: https://gerrit.libreoffice.org/39893 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Takeshi Abe <tabe@fixedpoint.jp>
Diffstat (limited to 'basic')
-rw-r--r--basic/qa/cppunit/test_scanner.cxx38
-rw-r--r--basic/source/comp/scanner.cxx2
2 files changed, 39 insertions, 1 deletions
diff --git a/basic/qa/cppunit/test_scanner.cxx b/basic/qa/cppunit/test_scanner.cxx
index 509a793f175a..1d6c7f37d4f2 100644
--- a/basic/qa/cppunit/test_scanner.cxx
+++ b/basic/qa/cppunit/test_scanner.cxx
@@ -28,6 +28,7 @@ namespace
OUString text;
double number;
SbxDataType type;
+ bool ws;
};
/**
@@ -46,6 +47,7 @@ namespace
void testNumbers();
void testDataType();
void testHexOctal();
+ void testTdf103104();
// Adds code needed to register the test suite
CPPUNIT_TEST_SUITE(ScannerTest);
@@ -61,6 +63,7 @@ namespace
CPPUNIT_TEST(testNumbers);
CPPUNIT_TEST(testDataType);
CPPUNIT_TEST(testHexOctal);
+ CPPUNIT_TEST(testTdf103104);
// End of test suite definition
CPPUNIT_TEST_SUITE_END();
@@ -87,6 +90,7 @@ namespace
symbol.text = scanner.GetSym();
symbol.number = scanner.GetDbl();
symbol.type = scanner.GetType();
+ symbol.ws = scanner.WhiteSpace();
symbols.push_back(symbol);
}
errors = scanner.GetErrors();
@@ -850,6 +854,40 @@ namespace
CPPUNIT_ASSERT_EQUAL(cr, symbols[2].text);
}
+ void ScannerTest::testTdf103104()
+ {
+ const OUString source1("asdf _\n asdf");
+ const OUString source2("asdf. _\n asdf");
+ const OUString source3("asdf _\n .asdf");
+
+ std::vector<Symbol> symbols;
+
+ symbols = getSymbols(source1);
+ CPPUNIT_ASSERT_EQUAL(size_t(3), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(asdf, symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(asdf, symbols[1].text);
+ CPPUNIT_ASSERT(symbols[1].ws);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[2].text);
+
+ symbols = getSymbols(source2);
+ CPPUNIT_ASSERT_EQUAL(size_t(4), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(asdf, symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(dot, symbols[1].text);
+ CPPUNIT_ASSERT(!symbols[1].ws);
+ CPPUNIT_ASSERT_EQUAL(asdf, symbols[2].text);
+ CPPUNIT_ASSERT(symbols[2].ws);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[3].text);
+
+ symbols = getSymbols(source3);
+ CPPUNIT_ASSERT_EQUAL(size_t(4), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(asdf, symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(dot, symbols[1].text);
+ CPPUNIT_ASSERT(!symbols[1].ws);
+ CPPUNIT_ASSERT_EQUAL(asdf, symbols[2].text);
+ CPPUNIT_ASSERT(!symbols[2].ws);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[3].text);
+ }
+
// Put the test suite in the registry
CPPUNIT_TEST_SUITE_REGISTRATION(ScannerTest);
} // namespace
diff --git a/basic/source/comp/scanner.cxx b/basic/source/comp/scanner.cxx
index 48072debbd15..0cf8ed49c6b3 100644
--- a/basic/source/comp/scanner.cxx
+++ b/basic/source/comp/scanner.cxx
@@ -626,7 +626,7 @@ eoln:
{
pLine = nullptr;
bool bRes = NextSym();
- if( bVBASupportOn && aSym.startsWith(".") )
+ if( aSym.startsWith(".") )
{
// object _
// .Method