You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by ja...@apache.org on 2013/02/06 19:37:55 UTC
svn commit: r1443117 - in /openoffice/branches/l10n/main/l10ntools/source:
gConSrc.cxx gConSrc.hxx gConSrcWrap.cxx gConSrclex.l
Author: jani
Date: Wed Feb 6 18:37:55 2013
New Revision: 1443117
URL: http://svn.apache.org/viewvc?rev=1443117&view=rev
Log:
added new handling of src files
Modified:
openoffice/branches/l10n/main/l10ntools/source/gConSrc.cxx
openoffice/branches/l10n/main/l10ntools/source/gConSrc.hxx
openoffice/branches/l10n/main/l10ntools/source/gConSrcWrap.cxx
openoffice/branches/l10n/main/l10ntools/source/gConSrclex.l
Modified: openoffice/branches/l10n/main/l10ntools/source/gConSrc.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConSrc.cxx?rev=1443117&r1=1443116&r2=1443117&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConSrc.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConSrc.cxx Wed Feb 6 18:37:55 2013
@@ -48,6 +48,21 @@ void convert_src::insert() {mcpImpl->in
/********************** I M P L E M E N T A T I O N **********************/
+src_stack_entry::src_stack_entry(string& sName)
+ : msName (sName)
+{
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+src_stack_entry::~src_stack_entry()
+{
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
convert_src_impl::convert_src_impl(const string& srSourceFile, l10nMem& crMemory)
: convert_gen(srSourceFile, crMemory),
mbCollectingData(false)
@@ -67,10 +82,10 @@ convert_src_impl::~convert_src_impl()
/********************** I M P L E M E N T A T I O N **********************/
void convert_src_impl::extract()
{
+ mbMergeMode = false;
+
// run lex parser and build token tree
runLex();
-
- //JIX
}
@@ -78,5 +93,8 @@ void convert_src_impl::extract()
/********************** I M P L E M E N T A T I O N **********************/
void convert_src_impl::insert()
{
- //JIX
+ mbMergeMode = true;
+
+ // run lex parser and build token tree
+ runLex();
}
Modified: openoffice/branches/l10n/main/l10ntools/source/gConSrc.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConSrc.hxx?rev=1443117&r1=1443116&r2=1443117&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConSrc.hxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConSrc.hxx Wed Feb 6 18:37:55 2013
@@ -21,6 +21,7 @@
#ifndef GCONSRCHXX
#define GCONSRCHXX
#include "gLang.hxx"
+#include <stack>
@@ -32,16 +33,16 @@
-/***************** T E M P L A T E D E F I N I T I O N *****************/
-#if 0
-template<typename T>
- void RemoveChars(std::basic_string<T> & Str, const T *CharsToRemove)
- {
- std::basic_string<T>::size_type pos = 0;
- while ( (pos = Str.find_first_of(CharsToRemove, pos)) != std::basic_string<T>::npos)
- Str.erase(pos, 1);
- }
-#endif
+/******************** C L A S S D E F I N I T I O N ********************/
+class src_stack_entry
+{
+ public:
+ src_stack_entry(string& sName);
+ ~src_stack_entry();
+
+ string msName;
+};
+
@@ -49,36 +50,27 @@ template<typename T>
class convert_src_impl : public convert_gen
{
public:
- typedef enum
- {
- IGNORED = 400,
- COMMEND, DEFINEDRES, ANYTOKEN, UNKNOWNTOKEN, UNKNOWNCONSTRUCTION, UNKNOWNCHAR,
- FILTER_LEVEL = 500,
- CONDITION, EMPTYLINE, RESSOURCE, RESSOURCEEXPR, SMALRESSOURCE, TEXTLINE,
- LONGTEXTLINE, TEXT, LEVELUP, LEVELDOWN, APPFONTMAPPING, ASSIGNMENT,
- LISTASSIGNMENT, LISTTEXT, RSCDEFINE, RSCDEFINELEND, NEWTEXTINRES, UIENTRIES,
- PRAGMA, _LISTTEXT, TEXTREFID, LISTRESID, _LISTRESID, NORMDEFINE
- } LEX_TOKENS;
-
convert_src_impl(const string& srSourceFile, l10nMem& crMemory);
~convert_src_impl();
- void addTokenToSet(LEX_TOKENS nToken, string srYYtext);
- void addCommentToSet(LEX_TOKENS nToken, string srYYtext);
+ void pushKey(string &sText);
+ void popKey ();
+ void pushNoKey();
+ void registerPushKey();
+ void pushRegistredKey(string &sText);
+
+ void saveData(string& sCollectedText);
+ void copyData(string& sCollectedText);
private:
- class tokenStorageEntry
- {
- public:
- tokenStorageEntry(LEX_TOKENS nToken, string& sYYtext): mnToken(nToken), msYYtext(sYYtext){};
- LEX_TOKENS mnToken;
- string msYYtext;
- };
+ stack<src_stack_entry> mcStack;
+ bool mbCollectingData;
+ string msCollector;
- void runLex();
void extract();
void insert();
- bool mbCollectingData;
+ void runLex();
+
friend class convert_src;
};
-#endif
+#endif
\ No newline at end of file
Modified: openoffice/branches/l10n/main/l10ntools/source/gConSrcWrap.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConSrcWrap.cxx?rev=1443117&r1=1443116&r2=1443117&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConSrcWrap.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConSrcWrap.cxx Wed Feb 6 18:37:55 2013
@@ -43,63 +43,56 @@ namespace SrcWrap
/********************** I M P L E M E N T A T I O N **********************/
-void convert_src_impl::addTokenToSet(LEX_TOKENS nToken, string srYYtext)
+void convert_src_impl::runLex()
{
-//JIX
-#if 0
- tokenStorage newToken;
+ SrcWrap::genSrc_lex();
+}
+
- newToken.mnToken = nToken;
- newToken.msYYtext = srYYtext;
- mcTokenSet.push_back(newToken);
-#endif
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_src_impl::pushKey(string &sText)
+{
}
/********************** I M P L E M E N T A T I O N **********************/
-void convert_src_impl::addCommentToSet(LEX_TOKENS nToken, string srYYtext)
+void convert_src_impl::popKey()
{
- char buf[2];
- bool check_comment_terminate;
+}
- // loop and collect whole comment
- for (check_comment_terminate = false, buf[1] = '\0';;)
- {
- buf[0] = SrcWrap::yyinput();
- // end of file ?
- if (!buf[0])
- break;
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_src_impl::pushNoKey()
+{
+}
- // remember byte
- srYYtext.append(buf);
- // did we receive ยด*' ?
- if (check_comment_terminate)
- {
- // end of comment ?
- if (buf[0] == '/')
- break;
- // it was not the end of comment
- check_comment_terminate = false;
- }
- else
- // Start on end of comment ?
- if (buf[0] == '*')
- check_comment_terminate = true;
- }
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_src_impl::registerPushKey()
+{
+}
- addTokenToSet(COMMEND, srYYtext);
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_src_impl::pushRegistredKey(string &sText)
+{
}
/********************** I M P L E M E N T A T I O N **********************/
-void convert_src_impl::runLex()
+void convert_src_impl::saveData(string& sCollectedText)
+{
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_src_impl::copyData(string& sCollectedText)
{
- SrcWrap::genSrc_lex();
}
Modified: openoffice/branches/l10n/main/l10ntools/source/gConSrclex.l
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConSrclex.l?rev=1443117&r1=1443116&r2=1443117&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConSrclex.l (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConSrclex.l Wed Feb 6 18:37:55 2013
@@ -23,7 +23,7 @@
/*****************************************************************************
********************** L E X D E F I N I T I O N **********************
*****************************************************************************
- * lex grammar for parsing ressource source files (*.src and *.hrc files)
+ * lex grammar for parsing ressource source files (*.src)
* file is converted to gConSrc_yy.cxx with "flex"
*****************************************************************************/
@@ -59,96 +59,56 @@
/******************* R U L E S D E F I N I T I O N S *******************/
%%
-^[\t ]*"#pragma".* {
- convert_src::mcpImpl->addTokenToSet(convert_src_impl::PRAGMA, string(yytext)); }
-
-^[ \t]*\n {
- convert_src::mcpImpl->addTokenToSet(convert_src_impl::EMPTYLINE, string(yytext)); }
-
-[\t ]+ |
-^[\t ]*"#include".* |
-^[\t ]*"#undef".* |
-"//".* |
-";" |
-"<" |
-">" |
-\n {
- convert_src::mcpImpl->addTokenToSet(convert_src_impl::IGNORED, string(yytext)); }
-
-"/*" {
- convert_src::mcpImpl->addCommentToSet(convert_src_impl::COMMEND, string(yytext)); }
-
-^[\t ]*"#ifndef".+$ |
-^[\t ]*"#ifdef".+$ |
-^[\t ]*"#if".+$ |
-^[\t ]*"#elif".+$ |
-^[\t ]*"#else".+$ |
-^[\t ]*"#endif".+$ {
- convert_src::mcpImpl->addTokenToSet(convert_src_impl::CONDITION, string(yytext)); }
-
-[a-zA-Z]+[\t ]+[^={\n]+[\t ] {
- convert_src::mcpImpl->addTokenToSet(convert_src_impl::DEFINEDRES, string(yytext)); /* defined Res */ }
-
-[a-zA-Z]+[ \t]+[^={;\n]+\n[ \t]*"#".*\n[ \t]*"{" |
-[a-zA-Z]+[ \t]+[^={;\n]+\n?([ \t]*"//".*\n)*[ \t]*"{" {
- convert_src::mcpImpl->addTokenToSet(convert_src_impl::RESSOURCE, string(yytext)); /* RESSOURCE // String TTT_XX ... */ }
-
-^[\t ]*[a-zA-Z_]+[\t ]*"\\"?[\t ]*\n?[ \t]*"{"[\t ]*"\\"? {
- convert_src::mcpImpl->addTokenToSet(convert_src_impl::SMALRESSOURCE, string(yytext)); /* SMALRESSOURCE // String ... */ }
-
-[\t ]*[a-zA-Z0-9_]+[ \t]*("["[ \t]*[a-zA-Z0-9_\-]+[ \t]*"]"[ \t]*)?=[ \t]*L?\".*\".*\n? {
- convert_src::mcpImpl->addTokenToSet(convert_src_impl::TEXTLINE, string(yytext)); /* TEXTLINE // TextTyp = "A Text" */ }
-
-[\t ]*[a-zA-Z0-9_]+[ \t]*("["[ \t]*[a-zA-Z0-9_\-]+[ \t]*"]"[ \t]*)?(\n[ \t]*)?=([ \t]*\n)?(([a-zA-Z0-9_]+)|(\".*\")|([ \t\n]*))*\".*\"(([a-zA-Z0-9_]+)|(\".*\")|([ \t\n]*))*; {
- convert_src::mcpImpl->addTokenToSet(convert_src_impl::LONGTEXTLINE, string(yytext)); /* LONGTEXTLINE // TextTyp = "A Text" HHH_XXX "A Text" ZZZ_TTT ... */ }
-
-\".*\" {
- convert_src::mcpImpl->addTokenToSet(convert_src_impl::TEXT, string(yytext)); /* TEXT // "A Text" */ }
-
-"{"[ \t]*\\? {
- convert_src::mcpImpl->addTokenToSet(convert_src_impl::LEVELUP, string(yytext)); /* LEVELUP */ }
-
-"}"[ \t]*;([ \t]*\\)? {
- convert_src::mcpImpl->addTokenToSet(convert_src_impl::LEVELDOWN, string(yytext)); /* LEVELDOWN */ }
-
-[a-zA-Z0-9_]+[ \t]*"="[ \t]*"MAP_APPFONT"[ \t]*"(".+")".* {
- convert_src::mcpImpl->addTokenToSet(convert_src_impl::APPFONTMAPPING, string(yytext)); /* APPFONTMAPPING Typ = MAP_APPFONT( ... ) */ }
-
-[ \t]*[a-zA-Z0-9_]+[ \t]*=[ \t]*[0123456789]{1,5}[ \t]*";"?\\? {
- convert_src::mcpImpl->addTokenToSet(convert_src_impl::TEXTREFID, string(yytext)); /* TEXTREFID // TextTyp = 12345 */ }
-
-[a-zA-Z0-9_]+[ \t]*"=".* |
-[a-zA-Z0-9_]+[ \t]*"="[\t ]*([ \t]*"//".*\n)*.* {
- convert_src::mcpImpl->addTokenToSet(convert_src_impl::ASSIGNMENT, string(yytext)); /* ASSIGNMENT Typ = ... */ }
-
-[a-zA-Z0-9_]+[ \t]*("["[ \t]*[a-zA-Z0-9_\-]+[ \t]*"]"[ \t]*)?"="[ \t]*(\\[ \t]*)?\n?[ \t]*"{"[ \t]*(\\[ \t]*)?\n?[ \t]*"<" {
- convert_src::mcpImpl->addTokenToSet(convert_src_impl::LISTASSIGNMENT, string(yytext)); /* LISTASSIGNMENT Typ [ ... ] = ... */ }
-
-"StringList"+[ \t]*("["[ \t]*[a-zA-Z0-9_\-]+[ \t]*"]"[ \t]*)?"="[ \t]*(\\[ \t]*)?\n?[ \t]*"{"[ \t]*(\\[ \t]*)?\n?[ \t]* {
- convert_src::mcpImpl->addTokenToSet(convert_src_impl::LISTASSIGNMENT, string(yytext)); /* LISTASSIGNMENT Typ [ ... ] = ... */ }
-
-"UIEntries"[ \t]*("["[ \t]*[a-zA-Z0-9_\-]+[ \t]*"]"[ \t]*)?"="[ \t]*(\\[ \t]*)?\n?[ \t]*"{" {
- convert_src::mcpImpl->addTokenToSet(convert_src_impl::UIENTRIES, string(yytext)); /* UIENTRIES */ }
-
-"<"?[ \t]*L?\".*\".*">" {
- convert_src::mcpImpl->addTokenToSet(convert_src_impl::LISTTEXT, string(yytext)); /* LISTTEXT */ }
-
-[ \t]*"#define"[ \t]+[a-zA-Z0-9_]+.*"\\" {
- convert_src::mcpImpl->addTokenToSet(convert_src_impl::RSCDEFINE, string(yytext)); /* RSCDEFINE #define ... */ }
-
-[ \t]*"#define"[ \t]+[a-zA-Z0-9_]+.+ {
- convert_src::mcpImpl->addTokenToSet(convert_src_impl::NORMDEFINE, string(yytext)); /* #define ... */ }
-
-"\\" {
- convert_src::mcpImpl->addTokenToSet(convert_src_impl::RSCDEFINELEND, string(yytext)); /* RSCDEFINELEND */ }
-
-[a-zA-Z0-9_]+[ \t]*; {
- convert_src::mcpImpl->addTokenToSet(convert_src_impl::ANYTOKEN, string(yytext)); /* allowed other tokens like "49 ;" or "SFX_... ;" */ }
-
-. {
- convert_src::mcpImpl->addTokenToSet(convert_src_impl::UNKNOWNCHAR, string(yytext)); /* YYWarning( "Unknown Char" ); */ }
-
-"{"?[ \t]*\".*\"[ \t]*";"[ \t]*"}" {
- convert_src::mcpImpl->addTokenToSet(convert_src_impl::_LISTTEXT, string(yytext)); /* _LISTTEXT */ }
+"TabDialog "[^\{]* {
+ string text(yytext);
+ convert_src::mcpImpl->pushKey(text);
+}
+
+"TabControl "[^\{]* {
+ string text(yytext);
+ convert_src::mcpImpl->pushKey(text);
+}
+
+"TabPage "[^\{]* {
+ string text(yytext);
+ convert_src::mcpImpl->pushKey(text);
+}
+
+"FixedText "[^\{]* {
+ string text(yytext);
+ convert_src::mcpImpl->pushKey(text);
+}
+
+"String "[^\{]* {
+ string text(yytext);
+ convert_src::mcpImpl->pushKey(text);
+}
+
+"PageList "[^\{]* {
+ convert_src::mcpImpl->pushNoKey();
+}
+
+"PageItem "[^\{]* {
+ convert_src::mcpImpl->registerPushKey();
+}
+
+"Identifier "[^;]* {
+ string text(yytext);
+ convert_src::mcpImpl->pushRegistredKey(text);
+}
+
+"Text "[^\"]*[^\"]*"\";" {
+ string text(yytext);
+ convert_src::mcpImpl->saveData(text);
+}
+
+"};" {
+ convert_src::mcpImpl->popKey();
+}
+
+.|\n {
+ string text(yytext);
+ convert_src::mcpImpl->copyData(text);
+}
%%