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/09 11:32:23 UTC
svn commit: r1444347 - in /openoffice/branches/l10n/main/l10ntools/source:
gConUlf.cxx gConUlf.hxx gConUlfWrap.cxx gConUlflex.l gLang.hxx makefile.mk
Author: jani
Date: Sat Feb 9 10:32:23 2013
New Revision: 1444347
URL: http://svn.apache.org/r1444347
Log:
added lex for ulf
Added:
openoffice/branches/l10n/main/l10ntools/source/gConUlf.hxx (with props)
openoffice/branches/l10n/main/l10ntools/source/gConUlfWrap.cxx (with props)
openoffice/branches/l10n/main/l10ntools/source/gConUlflex.l (with props)
Modified:
openoffice/branches/l10n/main/l10ntools/source/gConUlf.cxx
openoffice/branches/l10n/main/l10ntools/source/gLang.hxx
openoffice/branches/l10n/main/l10ntools/source/makefile.mk
Modified: openoffice/branches/l10n/main/l10ntools/source/gConUlf.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConUlf.cxx?rev=1444347&r1=1444346&r2=1444347&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConUlf.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConUlf.cxx Sat Feb 9 10:32:23 2013
@@ -18,7 +18,7 @@
* under the License.
*
*************************************************************/
-#include "gLang.hxx"
+#include "gConUlf.hxx"
@@ -30,35 +30,56 @@
+/***************************** G L O B A L S *****************************/
+convert_ulf_impl * convert_ulf::mcpImpl;
+
+
+
/********************** I M P L E M E N T A T I O N **********************/
convert_ulf::convert_ulf(const std::string& srSourceFile, l10nMem& crMemory, bool brVerbose)
- : convert_gen(srSourceFile, crMemory, brVerbose)
+ : convert_gen(srSourceFile, crMemory, brVerbose)
+ {mcpImpl = new convert_ulf_impl(srSourceFile, crMemory, brVerbose);}
+convert_ulf::~convert_ulf() {delete mcpImpl;}
+void convert_ulf::extract() {mcpImpl->extract();}
+void convert_ulf::insert() {mcpImpl->insert();}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+convert_ulf_impl::convert_ulf_impl(const std::string& srSourceFile, l10nMem& crMemory, bool brVerbose)
+ : convert_gen (srSourceFile, crMemory, brVerbose)
{
}
-/*****************************************************************************/
-convert_ulf::~convert_ulf()
+/********************** I M P L E M E N T A T I O N **********************/
+convert_ulf_impl::~convert_ulf_impl()
{
}
/*****************************************************************************/
-void convert_ulf::extract()
+void convert_ulf_impl::extract()
{
+ // generate l10mMem
mbMergeMode = false;
- handleLines();
+
+ // run lex parser and build token tree
+ runLex();
}
/*****************************************************************************/
-void convert_ulf::insert()
+void convert_ulf_impl::insert()
{
+ // generate l10mMem
mbMergeMode = true;
- handleLines();
+
+ // run lex parser and build token tree
+ runLex();
}
Added: openoffice/branches/l10n/main/l10ntools/source/gConUlf.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConUlf.hxx?rev=1444347&view=auto
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConUlf.hxx (added)
+++ openoffice/branches/l10n/main/l10ntools/source/gConUlf.hxx Sat Feb 9 10:32:23 2013
@@ -0,0 +1,56 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+#ifndef GCONULF_HXX
+#define GCONULF_HXX
+#include "gLang.hxx"
+
+
+
+/*****************************************************************************
+ ************************* G C O N U L F . H X X *************************
+ *****************************************************************************
+ * This is the class header for .ulf conversion
+ *****************************************************************************/
+
+
+
+/******************** C L A S S D E F I N I T I O N ********************/
+class convert_ulf_impl : public convert_gen
+{
+ public:
+ convert_ulf_impl(const std::string& srSourceFile, l10nMem& crMemory, bool brVerbose);
+ ~convert_ulf_impl();
+
+ void setKey(std::string &sCollectedText);
+ void setText(std::string &sCollectedText);
+ void collectData(std::string& sCollectedText);
+
+ private:
+ std::string msCollector;
+ std::string msKey;
+
+ void extract();
+ void insert();
+ void runLex();
+
+ friend class convert_ulf;
+};
+#endif
\ No newline at end of file
Propchange: openoffice/branches/l10n/main/l10ntools/source/gConUlf.hxx
------------------------------------------------------------------------------
svn:executable = *
Added: openoffice/branches/l10n/main/l10ntools/source/gConUlfWrap.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConUlfWrap.cxx?rev=1444347&view=auto
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConUlfWrap.cxx (added)
+++ openoffice/branches/l10n/main/l10ntools/source/gConUlfWrap.cxx Sat Feb 9 10:32:23 2013
@@ -0,0 +1,113 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+#include "gConUlf.hxx"
+
+
+
+/*****************************************************************************
+ ********************* G C O N X C S W R A P . C X X *********************
+ *****************************************************************************
+ * This includes the c code generated by flex
+ *****************************************************************************/
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+namespace UlfWrap
+{
+#include "gConUlf_yy.c"
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_ulf_impl::runLex()
+{
+ UlfWrap::genulf_lex();
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_ulf_impl::setKey(std::string& sCollectedText)
+{
+ if (mbMergeMode)
+ writeSourceFile(msCollector+sCollectedText);
+ msCollector.clear();
+
+ // locate key (is any)
+ msKey = sCollectedText.substr(1,sCollectedText.size()-2);
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_ulf_impl::setText(std::string& sCollectedText)
+{
+ int nL, nE;
+ std::string sText;
+
+
+ if (mbMergeMode)
+ writeSourceFile(msCollector+sCollectedText);
+ msCollector.clear();
+
+ // isolate text
+ nL = sCollectedText.find("\"");
+ if (nL == (int)std::string::npos)
+ return;
+ nE = sCollectedText.rfind("\"");
+ sText = sCollectedText.substr(nL+1,nE - nL -1);
+
+ if (mbMergeMode)
+ {
+ // get all languages (includes en-US)
+ std::vector<l10nMem_entry *>& cExtraLangauges = mcMemory.getLanguagesForKey(msKey);
+ std::string sNewLine;
+ nL = cExtraLangauges.size();
+
+ // and all other languages for that key
+ for (int i = 0; i < nL; ++i)
+ {
+ sNewLine = cExtraLangauges[i]->msLanguage + " = \"" +
+ cExtraLangauges[i]->msText +
+ "\"\n";
+
+ writeSourceFile(sNewLine);
+ }
+ }
+ else
+ mcMemory.setEnUsKey(msKey, msCollector);
+}
+
+
+
+/********************** I M P L E M E N T A T I O N **********************/
+void convert_ulf_impl::collectData(std::string& sCollectedText)
+{
+ msCollector += sCollectedText;
+ if (sCollectedText == "\n")
+ {
+ if (mbMergeMode)
+ writeSourceFile(msCollector);
+ msCollector.clear();
+ }
+}
Propchange: openoffice/branches/l10n/main/l10ntools/source/gConUlfWrap.cxx
------------------------------------------------------------------------------
svn:executable = *
Added: openoffice/branches/l10n/main/l10ntools/source/gConUlflex.l
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConUlflex.l?rev=1444347&view=auto
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConUlflex.l (added)
+++ openoffice/branches/l10n/main/l10ntools/source/gConUlflex.l Sat Feb 9 10:32:23 2013
@@ -0,0 +1,76 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+
+/*****************************************************************************
+ ********************** L E X D E F I N I T I O N **********************
+ *****************************************************************************
+ * lex grammar for parsing ressource source files (*.ulf files)
+ * file is converted to gConUlf_yy.cxx with "flex"
+ *****************************************************************************/
+
+
+
+/*************** O V E R W R I T I N G F U N C T I O N S ***************/
+%{
+/* enlarge token buffer to tokenize whole std::strings */
+#undef YYLMAX
+#define YYLMAX 64000
+
+/* change reader function (input) to our own version */
+#define YY_INPUT(buf,result,max_size) { convert_ulf::mcpImpl->lexRead(buf, &result, max_size); }
+%}
+
+
+
+/***************************** O P T I O N S *****************************/
+/* 8bit --> allow 8bit characters in the input stream */
+/* noyywrap --> yywrap is not called (single file scan) */
+/* never-interactive --> no check for console output */
+/* prefix= --> yyFlexLexer change name */
+/* --- The following options are for future use (maybe) */
+/* yyclass= --> subClass yyFlexLexer to allow own functions */
+/* c++ --> generate C++ classes */
+%option 8bit noyywrap never-interactive prefix="genulf_"
+%p 24000
+%e 1200
+%n 500
+
+
+
+/******************* R U L E S D E F I N I T I O N S *******************/
+%%
+
+"["[^\]]*"]" {
+ std::string text(yytext);
+ convert_ulf::mcpImpl->setKey(text);
+}
+
+"en-US"[ ]*"="[^\n]* {
+ std::string text(yytext);
+ convert_ulf::mcpImpl->setText(text);
+}
+
+.|\n {
+ std::string text(yytext);
+ convert_ulf::mcpImpl->collectData(text);
+}
+%%
Propchange: openoffice/branches/l10n/main/l10ntools/source/gConUlflex.l
------------------------------------------------------------------------------
svn:executable = *
Modified: openoffice/branches/l10n/main/l10ntools/source/gLang.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gLang.hxx?rev=1444347&r1=1444346&r2=1444347&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gLang.hxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gLang.hxx Sat Feb 9 10:32:23 2013
@@ -183,12 +183,15 @@ class convert_tree : public convert_gen
/******************** C L A S S D E F I N I T I O N ********************/
+class convert_ulf_impl;
class convert_ulf : public convert_gen
{
public:
- convert_ulf(const std::string& srSourceFile, l10nMem& srMemory, bool brVerbose);
+ static convert_ulf_impl *mcpImpl;
+
+ convert_ulf(const std::string& srSourceFile, l10nMem& srMemory, bool brVerbose);
~convert_ulf();
-
+
void extract();
void insert();
Modified: openoffice/branches/l10n/main/l10ntools/source/makefile.mk
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/makefile.mk?rev=1444347&r1=1444346&r2=1444347&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/makefile.mk (original)
+++ openoffice/branches/l10n/main/l10ntools/source/makefile.mk Sat Feb 9 10:32:23 2013
@@ -178,7 +178,7 @@ APP8OBJS= $(OBJ)$/gLang.obj $(OBJ)
$(OBJ)$/gConPoWrap.obj $(OBJ)$/gConHrcWrap.obj \
$(OBJ)$/gConSrcWrap.obj $(OBJ)$/gConXcsWrap.obj \
$(OBJ)$/gConXcuWrap.obj $(OBJ)$/gConXrmWrap.obj \
- $(OBJ)$/gConXhpWrap.obj
+ $(OBJ)$/gConXhpWrap.obj $(OBJ)$/gConUlfWrap.obj
APP8RPATH= NONE
APP8STDLIBS=
APP8LIBS=
@@ -225,6 +225,7 @@ $(OBJ)$/gConXcuWrap.obj: $(MISC)$/gConXc
$(OBJ)$/gConXcsWrap.obj: $(MISC)$/gConXcs_yy.c
$(OBJ)$/gConXrmWrap.obj: $(MISC)$/gConXrm_yy.c
$(OBJ)$/gConXhpWrap.obj: $(MISC)$/gConXhp_yy.c
+$(OBJ)$/gConUlfWrap.obj: $(MISC)$/gConUlf_yy.c
$(OBJ)$/src_yy_wrapper.obj: $(MISC)$/src_yy.c
$(OBJ)$/cfg_yy_wrapper.obj: $(MISC)$/cfg_yy.c