summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Power <noel.power@novell.com>2012-02-21 12:22:32 +0000
committerMiklos Vajna <vmiklos@suse.cz>2012-05-11 14:38:36 +0200
commitcf4410701e76cda3bf70032a5f1ac60c1ae9b261 (patch)
tree26b90cdcb7685e10d846429cdc15f1cf5d602c59
parent0a2f81a35d338c8e2d2da55df3fb221fa1de5bba (diff)
allow keyword Append to be used as a variable. bnc#745930
statements like Dim AppEnd As Integer will generate compiler errors because Append is a special symbol/keyword in libreoffice basic. This restriction though is too strict because 'Append' is only such a keyword when used within the 'Open' statement ( where it refers to one of the possible values for a paramater ). (cherry picked from commit 634b211632847dcb04b31f478296e5e6d732ac73) Signed-off-by: Miklos Vajna <vmiklos@suse.cz>
-rw-r--r--basic/source/comp/io.cxx2
-rw-r--r--basic/source/comp/scanner.cxx5
-rw-r--r--basic/source/comp/token.cxx9
-rw-r--r--basic/source/inc/scanner.hxx1
4 files changed, 15 insertions, 2 deletions
diff --git a/basic/source/comp/io.cxx b/basic/source/comp/io.cxx
index 038f20020d8c..f1c865e29d98 100644
--- a/basic/source/comp/io.cxx
+++ b/basic/source/comp/io.cxx
@@ -181,6 +181,7 @@ void SbiParser::Input()
void SbiParser::Open()
{
+ bInStatement = true;
SbiExpression aFileName( this );
SbiToken eTok;
TestToken( FOR );
@@ -277,6 +278,7 @@ void SbiParser::Open()
aGen.Gen( _OPEN, nMode, nFlags );
delete pLen;
delete pChan;
+ bInStatement = false;
}
// NAME file AS file
diff --git a/basic/source/comp/scanner.cxx b/basic/source/comp/scanner.cxx
index e1a5c756b072..4e1c4b1104d6 100644
--- a/basic/source/comp/scanner.cxx
+++ b/basic/source/comp/scanner.cxx
@@ -55,9 +55,10 @@ SbiScanner::SbiScanner( const ::rtl::OUString& rBuf, StarBASIC* p ) : aBuf( rBuf
bUsedForHilite =
bCompatible =
bVBASupportOn =
- bPrevLineExtentsComment = sal_False;
+ bInStatement =
+ bPrevLineExtentsComment = false;
bHash =
- bErrors = sal_True;
+ bErrors = true;
}
SbiScanner::~SbiScanner()
diff --git a/basic/source/comp/token.cxx b/basic/source/comp/token.cxx
index f8cc89a43d8e..657cd29b49b2 100644
--- a/basic/source/comp/token.cxx
+++ b/basic/source/comp/token.cxx
@@ -401,6 +401,15 @@ special:
return eCurTok = SYMBOL;
else if( tp->t == TEXT )
return eCurTok = SYMBOL;
+ // maybe we can expand this for other statements that have parameters
+ // that are keywords ( and those keywords are only used within such
+ // statements )
+ // what's happening here is that if we come across 'append' ( and we are
+ // not in the middle of parsing a special statement ( like 'Open')
+ // we just treat keyword 'append' as a normal 'SYMBOL'.
+ // Also we accept Dim APPEND
+ else if ( ( !bInStatement || eCurTok == DIM ) && tp->t == APPEND )
+ return eCurTok = SYMBOL;
// #i92642: Special LINE token handling -> SbiParser::Line()
diff --git a/basic/source/inc/scanner.hxx b/basic/source/inc/scanner.hxx
index 1bb554bd24ea..cd19cbffc2d0 100644
--- a/basic/source/inc/scanner.hxx
+++ b/basic/source/inc/scanner.hxx
@@ -74,6 +74,7 @@ protected:
bool bVBASupportOn; // sal_True: OPTION VBASupport 1 otherwise default False
bool bPrevLineExtentsComment; // sal_True: Previous line is comment and ends on "... _"
+ bool bInStatement;
void GenError( SbError );
public:
SbiScanner( const ::rtl::OUString&, StarBASIC* = NULL );