update ooo310-m15
[ooovba.git] / applied_patches / 0377-vba-keyword-fix.diff
blob2c95976ff6e3d30c8a34bc17405a6ed0ecfb13e3
1 --- basic/source/inc/token.hxx.orig 2008-07-30 11:33:31.000000000 +0800
2 +++ basic/source/inc/token.hxx 2008-07-30 16:54:58.000000000 +0800
3 @@ -162,6 +162,10 @@ public:
4 { return BOOL( t >= FIRSTKWD && t <= LASTKWD ); }
5 static BOOL IsExtra( SbiToken t )
6 { return BOOL( t >= FIRSTEXTRA ); }
8 + // process somthing like dim Name as String
9 + virtual BOOL IsSymbol( SbiToken )
10 + { return FALSE; }
14 --- basic/source/inc/parser.hxx.orig 2008-07-30 11:33:31.000000000 +0800
15 +++ basic/source/inc/parser.hxx 2008-07-30 16:54:58.000000000 +0800
16 @@ -40,6 +40,7 @@
17 typedef ::std::vector< String > IfaceVector;
19 struct SbiParseStack;
20 +struct SbiStatement;
22 class SbiParser : public SbiTokenizer
24 @@ -53,6 +54,7 @@ class SbiParser : public SbiTokenizer
25 BOOL bGblDefs; // TRUE globale Definitionen allgemein
26 BOOL bNewGblDefs; // TRUE globale Definitionen vor Sub
27 BOOL bSingleLineIf; // TRUE einzeiliges if-Statement
28 + SbiStatement* pCurStat;
30 SbiSymDef* VarDecl( SbiDimList**,BOOL,BOOL );// Variablen-Deklaration
31 SbiProcDef* ProcDecl(BOOL bDecl);// Prozedur-Deklaration
32 @@ -100,6 +102,7 @@ public:
33 BOOL TestSymbol( BOOL=FALSE ); // Symbol?
34 BOOL TestComma(); // Komma oder EOLN?
35 void TestEoln(); // EOLN?
36 + virtual BOOL IsSymbol( SbiToken t ); // Process something like DIM Name as String
38 void Symbol(); // Let oder Call
39 void ErrorStmnt(); // ERROR n
40 --- basic/source/comp/token.cxx.orig 2008-07-30 11:33:31.000000000 +0800
41 +++ basic/source/comp/token.cxx 2008-08-08 16:12:12.000000000 +0800
42 @@ -594,6 +594,13 @@ special:
44 return eCurTok;
47 + // check whether the keyword has been dim as a variable
48 + if( IsSymbol( tp->t ) )
49 + {
50 + return eCurTok = SYMBOL;
51 + }
53 // Sind Datentypen Keywords?
54 // Nur nach AS, sonst sind es Symbole!
55 // Es gibt ja ERROR(), DATA(), STRING() etc.
56 --- basic/source/comp/parser.cxx.orig 2008-07-30 11:33:33.000000000 +0800
57 +++ basic/source/comp/parser.cxx 2008-08-11 10:10:40.000000000 +0800
58 @@ -138,6 +138,7 @@ SbiParser::SbiParser( StarBASIC* pb, SbM
59 pProc = NULL;
60 pStack = NULL;
61 pWithVar = NULL;
62 + pCurStat = NULL;
63 nBase = 0;
64 bText =
65 bGblDefs =
66 @@ -308,6 +309,26 @@ void SbiParser::TestEoln()
70 +// If some keywords e.g. Name have been dim as a variable,
71 +// they should be treated as symbol
72 +BOOL SbiParser::IsSymbol( SbiToken t )
74 + // FIXME: if "name" is a argument in a subroutine like "Sub Test( name as String )".
75 + if( IsVBASupportOn() && ( t == NAME || t == LINE || t == TEXT ))
76 + {
77 + if( pCurStat && ( pCurStat->eTok == DIM || pCurStat->eTok == PUBLIC ||
78 + pCurStat->eTok == PRIVATE || pCurStat->eTok == GLOBAL ))
79 + {
80 + return TRUE;
81 + }
82 + if( pPool->Find(aSym) )
83 + {
84 + return TRUE;
85 + }
86 + }
87 + return FALSE;
90 // Parsing eines Statement-Blocks
91 // Das Parsing laeuft bis zum Ende-Token.
93 @@ -431,7 +452,9 @@ BOOL SbiParser::Parse()
94 if( ( p->bSubr && (eCurTok != STATIC || Peek() == SUB || Peek() == FUNCTION ) ) ||
95 eCurTok == SUB || eCurTok == FUNCTION )
96 aGen.Statement();
97 + pCurStat = p;
98 (this->*( p->Func ) )();
99 + pCurStat = NULL;
100 SbxError nSbxErr = SbxBase::GetError();
101 if( nSbxErr )
102 SbxBase::ResetError(), Error( (SbError)nSbxErr );
103 --- basic/source/comp/dim.cxx.orig 2008-07-31 14:54:31.000000000 +0800
104 +++ basic/source/comp/dim.cxx 2008-08-11 10:12:22.000000000 +0800
105 @@ -40,7 +40,10 @@
107 SbiSymDef* SbiParser::VarDecl( SbiDimList** ppDim, BOOL bStatic, BOOL bConst )
109 - if( !TestSymbol() ) return NULL;
110 + // Some keywords can be dim as varibles like " Sub Test( Name as String )"
111 + eCurTok = Peek();
112 + BOOL bKwdOk = IsVBASupportOn() ? BOOL( (eCurTok == NAME) || (eCurTok == LINE) || (eCurTok == TEXT) ): FALSE;
113 + if( !TestSymbol( bKwdOk ) ) return NULL;
114 SbxDataType t = eScanType;
115 SbiSymDef* pDef = bConst ? new SbiConstDef( aSym ) : new SbiSymDef( aSym );
116 SbiDimList* pDim = NULL;