diff options
author | Jan Iversen <jani@documentfoundation.org> | 2016-03-01 18:07:54 +0100 |
---|---|---|
committer | jan iversen <jani@documentfoundation.org> | 2016-03-03 07:46:59 +0000 |
commit | 999c68f12f1d95b16a97294949a0e6ba6d3ba259 (patch) | |
tree | 0abb13f0fa1ab353771f1eda05e4abadc554ef2c /l10ntools/source/gLexXcu.l | |
parent | b76842f63b19e9855fbdfee7c201ff73672464b6 (diff) |
genLang project (awareness)
the genLang project aims at replacing all l10ntools with more
modern versions, based on C++ and lex.
The current extract works basically as a standalone "find" over the
source tree. genLang can use that, but also a more efficient way, by
having translation-worthy files declared in the makefile stubs.
genLang itself is a C++ framework, where each file type is defined as
a class, making it easy to add new file types.
genLang can easily be adopted to transform the help files into e.g.
mediawiki format, and later merge a url back into the code.
The project was first developed (solely by the author) in a non
published branch of OO. This branch was never merged but deleted
and therefore never published.
The files have been adapted to the LO build system and setup.
The primary commit is just to raise awareness, that this is being
developed. The following commit, will update the source code to LO
standard. Before replacing the old modules a dedicated review will
be asked for.
Change-Id: I4504992474333c476c179903f822bfaf1441cca9
Reviewed-on: https://gerrit.libreoffice.org/22819
Reviewed-by: jan iversen <jani@documentfoundation.org>
Tested-by: jan iversen <jani@documentfoundation.org>
Diffstat (limited to 'l10ntools/source/gLexXcu.l')
-rw-r--r-- | l10ntools/source/gLexXcu.l | 161 |
1 files changed, 161 insertions, 0 deletions
diff --git a/l10ntools/source/gLexXcu.l b/l10ntools/source/gLexXcu.l new file mode 100644 index 000000000000..c5579076dab5 --- /dev/null +++ b/l10ntools/source/gLexXcu.l @@ -0,0 +1,161 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * 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 . + */ + + +/***************************************************************************** + ********************** L E X D E F I N I T I O N ********************** + ***************************************************************************** + * lex grammar for parsing ressource source files (*.xrm files) + * file is converted to gConXcu_yy.cxx with "flex" + *****************************************************************************/ + + + +/*************** O V E R W R I T I N G F U N C T I O N S ***************/ +%top{ +#include "gConvXcu.hxx" + +#define IMPLptr convert_gen_impl::mcImpl +#define LOCptr ((convert_xcu *)convert_gen_impl::mcImpl) + +/* 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) {int xres; IMPLptr->lexRead(buf, &xres, max_size); result = xres;} + +#define yytext_ptr xcutext_ptr +#define YY_NO_UNISTD_H 1 +} + +%{ +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +%} + + + + + +/***************************** 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 prefix="xcu" 8bit noyywrap never-interactive +%array +%p 24000 +%e 1200 +%n 500 + + + +/*********************** H E L P E R M A C R O S ***********************/ +SPACE [ \t]* +NAME .*"oor:name="\"[^\"]+\"{SPACE} +FIN [^/>]*">" +/******************* R U L E S D E F I N I T I O N S *******************/ +%% + + + +"component-data" { + LOCptr->addLevel(); + IMPLptr->copySource(yytext, false); +} + + + +"<oor:component-data"{NAME} { + LOCptr->addLevel(); + LOCptr->pushKey(yytext); +} + + + +"<prop"{NAME}{FIN} | +"<node"{NAME}{FIN} { + LOCptr->pushKey(yytext); +} + + + +"</oor:component-data" | +"</prop" | +"</node" { + LOCptr->popKey(yytext); +} + + +"<value xml:lang="\"[^\"]+\"[^>]*">" { + LOCptr->startCollectData(yytext); +} + + + +"</value>" { + LOCptr->stopCollectData(yytext); +} + + + +"&" | +"'" | +">" | +"<" | +""" { + LOCptr->copySpecial(yytext); +} + + + +({SPACE}\n{SPACE})+ { + LOCptr->copyNL(yytext); +} + + + +. { + IMPLptr->copySource(yytext, LOCptr->mbNoCollectingData); + + // Just to please compiler. + if (false) + REJECT; +} + + + +%% + + + +void xcu_dummyJustForCompiler() +{ +// char *txt = NULL; +// yy_flex_strlen(txt); +// yyunput(0, txt); +} |