[Uml-devel] branches/KDE/3.5/kdesdk/umbrello/umbrello/codeimport
Oliver Kellogg
okellogg at users.sourceforge.net
Sat Aug 12 04:04:55 UTC 2006
SVN commit 572263 by okellogg:
skipToClosing(): Move from JavaImport to NativeImportBase.
PascalImport::parseFile(): Fix parameter mode handling. Implement subprogram
pointer type.
M +0 -41 javaimport.cpp
M +0 -11 javaimport.h
M +41 -0 nativeimportbase.cpp
M +10 -0 nativeimportbase.h
M +31 -15 pascalimport.cpp
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codeimport/javaimport.cpp #572262:572263
@@ -92,48 +92,7 @@
m_source.append(lexeme);
}
-bool JavaImport::skipToClosing(QChar opener) {
- QString closing;
- switch (opener) {
- case '{':
- closing = "}";
- break;
- case '[':
- closing = "]";
- break;
- case '(':
- closing = ")";
- break;
- case '<':
- closing = ">";
- break;
- default:
- kdError() << "JavaImport::skipToClosing(" << opener
- << "): " << "illegal input character" << endl;
- return false;
- }
- const QString opening(opener);
- skipStmt(opening);
- const uint srcLength = m_source.count();
- int nesting = 0;
- while (m_srcIndex < srcLength) {
- QString nextToken = advance();
- if (nextToken.isEmpty())
- break;
- if (nextToken == closing) {
- if (nesting <= 0)
- break;
- nesting--;
- } else if (nextToken == opening) {
- nesting++;
- }
- }
- if (m_srcIndex == srcLength)
- return false;
- return true;
-}
-
///Spawn off an import of the specifed file
void JavaImport::spawnImport( QString file ) {
// if the file is being parsed, don't bother
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codeimport/javaimport.h #572262:572263
@@ -43,17 +43,6 @@
void fillSource(QString word);
/**
- * Advance NativeImportBase::m_srcIndex to the index of the
- * corresponding closing character of the given opening.
- * Nested opening/closing pairs are respected.
- * Valid openers are: '{' '[' '(' '<'
- *
- * @return True for success, false for misuse (invalid opener) or
- * if no matching closing character is found in m_source.
- */
- bool skipToClosing(QChar opener);
-
- /**
* Keep track of the filename currently being parsed
*/
void parseFile(QString filename);
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codeimport/nativeimportbase.cpp #572262:572263
@@ -50,6 +50,47 @@
m_srcIndex++;
}
+bool NativeImportBase::skipToClosing(QChar opener) {
+ QString closing;
+ switch (opener) {
+ case '{':
+ closing = "}";
+ break;
+ case '[':
+ closing = "]";
+ break;
+ case '(':
+ closing = ")";
+ break;
+ case '<':
+ closing = ">";
+ break;
+ default:
+ kdError() << "JavaImport::skipToClosing(" << opener
+ << "): " << "illegal input character" << endl;
+ return false;
+ }
+ const QString opening(opener);
+ skipStmt(opening);
+ const uint srcLength = m_source.count();
+ int nesting = 0;
+ while (m_srcIndex < srcLength) {
+ QString nextToken = advance();
+ if (nextToken.isEmpty())
+ break;
+ if (nextToken == closing) {
+ if (nesting <= 0)
+ break;
+ nesting--;
+ } else if (nextToken == opening) {
+ nesting++;
+ }
+ }
+ if (m_srcIndex == srcLength)
+ return false;
+ return true;
+}
+
QString NativeImportBase::advance() {
while (m_srcIndex < m_source.count() - 1) {
if (m_source[++m_srcIndex].startsWith(m_singleLineCommentIntro))
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codeimport/nativeimportbase.h #572262:572263
@@ -134,6 +134,16 @@
void skipStmt(QString until = ";");
/**
+ * Advance m_srcIndex to the index of the corresponding closing character
+ * of the given opening. Nested opening/closing pairs are respected.
+ * Valid openers are: '{' '[' '(' '<'
+ *
+ * @return True for success, false for misuse (invalid opener) or
+ * if no matching closing character is found in m_source.
+ */
+ bool skipToClosing(QChar opener);
+
+ /**
* Advance m_srcIndex until m_source[m_srcIndex] contains a non-comment.
* Comments encountered during advancement are accumulated in `m_comment'.
* If m_srcIndex hits the end of m_source then QString::null is returned.
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codeimport/pascalimport.cpp #572262:572263
@@ -225,6 +225,17 @@
advance();
const uint MAX_PARNAMES = 16;
while (m_srcIndex < srcLength && m_source[m_srcIndex] != ")") {
+ QString nextToken = m_source[m_srcIndex + 1].lower();
+ Uml::Parameter_Direction dir = Uml::pd_In;
+ if (nextToken == "var") {
+ dir = Uml::pd_InOut;
+ advance();
+ } else if (nextToken == "const") {
+ advance();
+ } else if (nextToken == "out") {
+ dir = Uml::pd_Out;
+ advance();
+ }
QString parName[MAX_PARNAMES];
uint parNameCount = 0;
do {
@@ -235,26 +246,23 @@
parName[parNameCount++] = advance();
} while (advance() == ",");
if (m_source[m_srcIndex] != ":") {
- kdError() << "importPascal: expecting ':'" << endl;
+ kdError() << "importPascal: expecting ':' at " << m_source[m_srcIndex] << endl;
skipStmt();
break;
}
- const QString parMode = advance().lower();
- QString typeName;
- Uml::Parameter_Direction dir = Uml::pd_In;
- if (parMode == "var") {
- dir = Uml::pd_InOut;
- typeName = advance();
- } else if (parMode == "const") {
- typeName = advance();
- } else if (parMode == "out") {
- dir = Uml::pd_Out;
- typeName = advance();
- } else {
- typeName = parMode; // The default is "pass by value".
+ nextToken = advance();
+ if (nextToken.lower() == "array") {
+ nextToken = advance().lower();
+ if (nextToken != "of") {
+ kdError() << "importPascal(" << name << "): expecting 'array OF' at "
+ << nextToken << endl;
+ skipStmt();
+ return false;
+ }
+ nextToken = advance();
}
for (uint i = 0; i < parNameCount; i++) {
- UMLAttribute *att = Import_Utils::addMethodParameter(op, typeName, parName[i]);
+ UMLAttribute *att = Import_Utils::addMethodParameter(op, nextToken, parName[i]);
att->setParmKind(dir);
}
if (advance() != ";")
@@ -347,6 +355,14 @@
m_klass = static_cast<UMLClassifier*>(ns);
return true;
}
+ if (keyword == "function" || keyword == "procedure") {
+ UMLObject *ns = Import_Utils::createUMLObject(Uml::ot_Datatype, name,
+ m_scope[m_scopeIndex], m_comment);
+ if (m_source[m_srcIndex + 1] == "(")
+ skipToClosing('(');
+ skipStmt();
+ return true;
+ }
// Datatypes: TO BE DONE
return false;
}
More information about the umbrello-devel
mailing list