|
@@ -2,17 +2,17 @@
|
|
|
|
|
|
using namespace KSGScript;
|
|
|
|
|
|
-const char *( ColorParser::keyword[] ) = { "lesen", "var", "func", "Rückruf", "class", "public", "private", "if", "else", "return", "break", "continue", "for", "while" };
|
|
|
+const char* (ColorParser::keyword[]) = { "lesen", "var", "func", "Rückruf", "class", "public", "private", "if", "else", "return", "break", "continue", "for", "while" };
|
|
|
const int ColorParser::keywordAnz = 14;
|
|
|
-const char *( ColorParser::type[] ) = { "void", "bool", "int", "double", "Array", "Thread", "Text", "Bild", "MausEreignis", "TastaturEreignis", "TextFeld", "Knopf", "Fenster", "BildZ", "Animation2DData", "Animation2D" };
|
|
|
+const char* (ColorParser::type[]) = { "void", "bool", "int", "double", "Array", "Thread", "Text", "Bild", "MausEreignis", "TastaturEreignis", "TextFeld", "Knopf", "Fenster", "BildZ", "Animation2DData", "Animation2D" };
|
|
|
const int ColorParser::typeAnz = 16;
|
|
|
|
|
|
// Konstructor
|
|
|
// zTxt: Der Text, der geparsed werden soll
|
|
|
-ColorParser::ColorParser( Text *zTxt )
|
|
|
+ColorParser::ColorParser( Text* zTxt )
|
|
|
: KSGSLeser()
|
|
|
{
|
|
|
- txt = dynamic_cast<Text *>( zTxt->getThis() );
|
|
|
+ txt = dynamic_cast<Text*>(zTxt->getThis());
|
|
|
reset();
|
|
|
reload();
|
|
|
}
|
|
@@ -20,12 +20,12 @@ ColorParser::ColorParser( Text *zTxt )
|
|
|
// Destructor
|
|
|
ColorParser::~ColorParser()
|
|
|
{
|
|
|
- for( auto i = abschnitt.getIterator(); i; i++ )
|
|
|
+ for( auto i : abschnitt )
|
|
|
{
|
|
|
- if( i._.zFunktion )
|
|
|
- i._.zFunktion->release();
|
|
|
- if( i._.zKlasse )
|
|
|
- i._.zKlasse->release();
|
|
|
+ if( i.zFunktion )
|
|
|
+ i.zFunktion->release();
|
|
|
+ if( i.zKlasse )
|
|
|
+ i.zKlasse->release();
|
|
|
}
|
|
|
txt->release();
|
|
|
}
|
|
@@ -72,17 +72,17 @@ void ColorParser::reload()
|
|
|
error.leeren();
|
|
|
string.leeren();
|
|
|
kommentar.leeren();
|
|
|
- for( auto i = abschnitt.getIterator(); i; i++ )
|
|
|
+ for( auto i : abschnitt )
|
|
|
{
|
|
|
- if( i._.zFunktion )
|
|
|
- i._.zFunktion->release();
|
|
|
- if( i._.zKlasse )
|
|
|
- i._.zKlasse->release();
|
|
|
+ if( i.zFunktion )
|
|
|
+ i.zFunktion->release();
|
|
|
+ if( i.zKlasse )
|
|
|
+ i.zKlasse->release();
|
|
|
}
|
|
|
abschnitt.leeren();
|
|
|
delete dat;
|
|
|
dat = new KSGSLeseScript();
|
|
|
- d = new TextReader( dynamic_cast<Text *>( txt->getThis() ) );
|
|
|
+ d = new TextReader( dynamic_cast<Text*>(txt->getThis()) );
|
|
|
zeile = 1;
|
|
|
while( !d->istEnde() )
|
|
|
{
|
|
@@ -95,7 +95,7 @@ void ColorParser::reload()
|
|
|
case 1: // Klasse
|
|
|
if( 1 )
|
|
|
{
|
|
|
- KSGSLeseKlasse *k = leseKlasse();
|
|
|
+ KSGSLeseKlasse* k = leseKlasse();
|
|
|
if( !k )
|
|
|
{
|
|
|
//error( 6, { "Klasse", *pfad }, zObj );
|
|
@@ -108,7 +108,7 @@ void ColorParser::reload()
|
|
|
case 2: // funktion
|
|
|
if( 1 )
|
|
|
{
|
|
|
- KSGSLeseFunktion *f = leseFunktion();
|
|
|
+ KSGSLeseFunktion* f = leseFunktion();
|
|
|
if( !f )
|
|
|
{
|
|
|
//error( 6, { "Funktion", *pfad }, zObj );
|
|
@@ -121,7 +121,7 @@ void ColorParser::reload()
|
|
|
case 3: // Variable
|
|
|
if( 1 )
|
|
|
{
|
|
|
- KSGSLeseVariable *v = leseVariable();
|
|
|
+ KSGSLeseVariable* v = leseVariable();
|
|
|
if( !v )
|
|
|
{
|
|
|
//error( 6, { "Variable", *pfad }, zObj );
|
|
@@ -155,10 +155,10 @@ void ColorParser::reload()
|
|
|
br = 1;
|
|
|
break;
|
|
|
}
|
|
|
- char *datei = new char[ (int)( end - d->getLPosition() ) + 1 ];
|
|
|
+ char* datei = new char[ (int)(end - d->getLPosition()) + 1 ];
|
|
|
datei[ end - d->getLPosition() ] = 0;
|
|
|
- d->lese( datei, (int)( end - d->getLPosition() ) );
|
|
|
- Text *dPf = new Text( datei );
|
|
|
+ d->lese( datei, (int)(end - d->getLPosition()) );
|
|
|
+ Text* dPf = new Text( datei );
|
|
|
dPf->ersetzen( '\\', '/' );
|
|
|
if( dPf->getText()[ 0 ] == '/' )
|
|
|
dPf->remove( 0 );
|
|
@@ -172,9 +172,9 @@ void ColorParser::reload()
|
|
|
break;
|
|
|
}
|
|
|
d->setLPosition( d->getLPosition() + 1, 0 );
|
|
|
- Text *pf = new Text( fileName );
|
|
|
+ Text* pf = new Text( fileName );
|
|
|
fileName.setText( dPf );
|
|
|
- Reader *tmp = d;
|
|
|
+ Reader* tmp = d;
|
|
|
if( !ladeDatei() )
|
|
|
{
|
|
|
handleError( (int)d->getLPosition() - 1, (int)d->getLPosition() );
|
|
@@ -202,14 +202,14 @@ void ColorParser::reload()
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- d = (Reader *)( (TextReader *)d )->release();
|
|
|
+ d = (Reader*)((TextReader*)d)->release();
|
|
|
}
|
|
|
|
|
|
-KSGSLeseKlasse *ColorParser::leseKlasse()
|
|
|
+KSGSLeseKlasse* ColorParser::leseKlasse()
|
|
|
{
|
|
|
Abschnitt abs;
|
|
|
abs.anfang = (int)d->getLPosition();
|
|
|
- KSGSLeseKlasse *ret = KSGSLeser::leseKlasse();
|
|
|
+ KSGSLeseKlasse* ret = KSGSLeser::leseKlasse();
|
|
|
abs.ende = (int)d->getLPosition();
|
|
|
abs.zKlasse = ret;
|
|
|
abs.zFunktion = 0;
|
|
@@ -219,11 +219,11 @@ KSGSLeseKlasse *ColorParser::leseKlasse()
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
-KSGSLeseFunktion *ColorParser::leseFunktion()
|
|
|
+KSGSLeseFunktion* ColorParser::leseFunktion()
|
|
|
{
|
|
|
Abschnitt abs;
|
|
|
abs.anfang = (int)d->getLPosition();
|
|
|
- KSGSLeseFunktion *ret = KSGSLeser::leseFunktion();
|
|
|
+ KSGSLeseFunktion* ret = KSGSLeser::leseFunktion();
|
|
|
abs.ende = (int)d->getLPosition();
|
|
|
abs.zKlasse = 0;
|
|
|
abs.zFunktion = ret;
|
|
@@ -234,7 +234,7 @@ KSGSLeseFunktion *ColorParser::leseFunktion()
|
|
|
}
|
|
|
|
|
|
// Gibt den Farbtyp des nächsten Zeichens zurück
|
|
|
-KSGScriptEditor::ColorType ColorParser::getNextColor( int p, int &underlineC )
|
|
|
+KSGScriptEditor::ColorType ColorParser::getNextColor( int p, int& underlineC )
|
|
|
{
|
|
|
KSGScriptEditor::ColorType color = KSGScriptEditor::ColorType::NORMAL_TEXT;
|
|
|
int scriptL = txt->getLength();
|
|
@@ -248,14 +248,14 @@ KSGScriptEditor::ColorType ColorParser::getNextColor( int p, int &underlineC )
|
|
|
}
|
|
|
bool inString = 0;
|
|
|
bool inKommentar = 0;
|
|
|
- for( auto i = string.getIterator(); i; i++ )
|
|
|
+ for( auto i : string )
|
|
|
{
|
|
|
- if( i._.anfang <= p && i._.ende >= p )
|
|
|
+ if( i.anfang <= p && i.ende >= p )
|
|
|
inString = 1;
|
|
|
}
|
|
|
- for( auto i = kommentar.getIterator(); i; i++ )
|
|
|
+ for( auto i : kommentar )
|
|
|
{
|
|
|
- if( i._.anfang <= p && i._.ende >= p )
|
|
|
+ if( i.anfang <= p && i.ende >= p )
|
|
|
inKommentar = 1;
|
|
|
}
|
|
|
if( !inString && !inKommentar )
|
|
@@ -268,7 +268,7 @@ KSGScriptEditor::ColorType ColorParser::getNextColor( int p, int &underlineC )
|
|
|
pos.inKeyword = 1;
|
|
|
for( int j = 0; j < kl && j + p < scriptL && pos.inKeyword; j++ )
|
|
|
pos.inKeyword &= txt->getText()[ j + p ] == keyword[ i ][ j ];
|
|
|
- if( pos.inKeyword && ( kl + p == scriptL || istTrenner( txt->getText()[ kl + p ] ) ) )
|
|
|
+ if( pos.inKeyword && (kl + p == scriptL || istTrenner( txt->getText()[ kl + p ] )) )
|
|
|
break;
|
|
|
pos.inKeyword = 0;
|
|
|
}
|
|
@@ -281,7 +281,7 @@ KSGScriptEditor::ColorType ColorParser::getNextColor( int p, int &underlineC )
|
|
|
pos.inTypename = 1;
|
|
|
for( int j = 0; j < tl && j + p < scriptL && pos.inTypename; j++ )
|
|
|
pos.inTypename &= txt->getText()[ j + p ] == type[ i ][ j ];
|
|
|
- if( pos.inTypename && ( tl + p == scriptL || istTrenner( txt->getText()[ tl + p ] ) ) )
|
|
|
+ if( pos.inTypename && (tl + p == scriptL || istTrenner( txt->getText()[ tl + p ] )) )
|
|
|
break;
|
|
|
pos.inTypename = 0;
|
|
|
}
|
|
@@ -294,7 +294,7 @@ KSGScriptEditor::ColorType ColorParser::getNextColor( int p, int &underlineC )
|
|
|
pos.inTypename = 1;
|
|
|
for( int j = 0; j < tl && j + p < scriptL && pos.inTypename; j++ )
|
|
|
pos.inTypename &= txt->getText()[ j + p ] == dat->klassen.get( i )->name.getText()[ j ];
|
|
|
- if( pos.inTypename && ( tl + p == scriptL || istTrenner( txt->getText()[ tl + p ] ) ) )
|
|
|
+ if( pos.inTypename && (tl + p == scriptL || istTrenner( txt->getText()[ tl + p ] )) )
|
|
|
break;
|
|
|
pos.inTypename = 0;
|
|
|
}
|
|
@@ -302,20 +302,20 @@ KSGScriptEditor::ColorType ColorParser::getNextColor( int p, int &underlineC )
|
|
|
}
|
|
|
if( !pos.inInstanzVar && !pos.inParameter && !pos.inKeyword && !pos.inTypename && istLehr( cm1 ) )
|
|
|
{
|
|
|
- for( auto i = abschnitt.getIterator(); i; i++ )
|
|
|
+ for( const Abschnitt& i : abschnitt )
|
|
|
{
|
|
|
- if( i._.anfang <= p && i._.ende >= p )
|
|
|
+ if( i.anfang <= p && i.ende >= p )
|
|
|
{
|
|
|
- if( i._.zFunktion )
|
|
|
+ if( i.zFunktion )
|
|
|
{
|
|
|
- int anz = i._.zFunktion->parameter.getEintragAnzahl();
|
|
|
+ int anz = i.zFunktion->parameter.getEintragAnzahl();
|
|
|
for( int j = 0; j < anz; j++ )
|
|
|
{
|
|
|
- int nl = i._.zFunktion->parameter.get( j )->name.getLength();
|
|
|
+ int nl = i.zFunktion->parameter.get( j )->name.getLength();
|
|
|
pos.inParameter = 1;
|
|
|
for( int k = 0; k < nl && k + p < scriptL && pos.inParameter; k++ )
|
|
|
- pos.inParameter &= txt->getText()[ k + p ] == i._.zFunktion->parameter.get( j )->name.getText()[ k ];
|
|
|
- if( pos.inParameter && ( nl + p == scriptL || istTrenner( txt->getText()[ nl + p ] ) ) )
|
|
|
+ pos.inParameter &= txt->getText()[ k + p ] == i.zFunktion->parameter.get( j )->name.getText()[ k ];
|
|
|
+ if( pos.inParameter && (nl + p == scriptL || istTrenner( txt->getText()[ nl + p ] )) )
|
|
|
break;
|
|
|
pos.inParameter = 0;
|
|
|
}
|
|
@@ -325,20 +325,20 @@ KSGScriptEditor::ColorType ColorParser::getNextColor( int p, int &underlineC )
|
|
|
}
|
|
|
if( !pos.inInstanzVar && !pos.inParameter && !pos.inKeyword && !pos.inTypename && istLehr( cm1 ) )
|
|
|
{
|
|
|
- for( auto i = abschnitt.getIterator(); i; i++ )
|
|
|
+ for( const Abschnitt& i : abschnitt )
|
|
|
{
|
|
|
- if( i._.anfang <= p && i._.ende >= p )
|
|
|
+ if( i.anfang <= p && i.ende >= p )
|
|
|
{
|
|
|
- if( i._.zKlasse )
|
|
|
+ if( i.zKlasse )
|
|
|
{
|
|
|
- int anz = i._.zKlasse->variablen.getEintragAnzahl();
|
|
|
+ int anz = i.zKlasse->variablen.getEintragAnzahl();
|
|
|
for( int j = 0; j < anz; j++ )
|
|
|
{
|
|
|
- int nl = i._.zKlasse->variablen.get( j )->name.getLength();
|
|
|
+ int nl = i.zKlasse->variablen.get( j )->name.getLength();
|
|
|
pos.inInstanzVar = 1;
|
|
|
for( int k = 0; k < nl && k + p < scriptL && pos.inInstanzVar; k++ )
|
|
|
- pos.inInstanzVar &= txt->getText()[ k + p ] == i._.zKlasse->variablen.get( j )->name.getText()[ k ];
|
|
|
- if( pos.inInstanzVar && ( nl + p == scriptL || istTrenner( txt->getText()[ nl + p ] ) ) )
|
|
|
+ pos.inInstanzVar &= txt->getText()[ k + p ] == i.zKlasse->variablen.get( j )->name.getText()[ k ];
|
|
|
+ if( pos.inInstanzVar && (nl + p == scriptL || istTrenner( txt->getText()[ nl + p ] )) )
|
|
|
break;
|
|
|
pos.inInstanzVar = 0;
|
|
|
}
|
|
@@ -359,10 +359,10 @@ KSGScriptEditor::ColorType ColorParser::getNextColor( int p, int &underlineC )
|
|
|
color = KSGScriptEditor::ColorType::STRING;
|
|
|
if( inKommentar )
|
|
|
color = KSGScriptEditor::ColorType::KOMMENTAR;
|
|
|
- for( auto i = error.getIterator(); i; i++ )
|
|
|
+ for( auto i : error )
|
|
|
{
|
|
|
- if( i._.anfang <= p && i._.ende >= p )
|
|
|
- underlineC = KSGScriptEditor::ColorType::ERROR_UNDERLINE;
|
|
|
+ if( i.anfang <= p && i.ende >= p )
|
|
|
+ underlineC = (int)KSGScriptEditor::ColorType::ERROR_UNDERLINE;
|
|
|
}
|
|
|
return color;
|
|
|
}
|