4 # This file is part of the LibreOffice project.
6 # This Source Code Form is subject to the terms of the Mozilla Public
7 # License, v. 2.0. If a copy of the MPL was not distributed with this
8 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
16 open ( TOKENS
, $ARGV0 ) || die "can't open token file: $!";
19 while ( defined ($line = <TOKENS
>) )
21 if( !($line =~ /^#/) )
24 @token = split(/\s+/,$line);
25 if ( not defined ($token[1]) )
27 $token[1] = "XML_".$token[0];
28 $token[1] =~ tr/\-\.\:/___/;
29 $token[1] =~ s/\+/PLUS/g;
30 $token[1] =~ s/\-/MINUS/g;
33 $tokens{$token[0]} = uc($token[1]);
38 open ( HXX
, ">$ARGV1" ) || die "can't open tokens.hxx file: $!";
39 open ( GPERF
, ">$ARGV2" ) || die "can't open tokens.gperf file: $!";
41 print ( GPERF
"%language=C++\n" );
42 print ( GPERF
"%global-table\n" );
43 print ( GPERF
"%null-strings\n" );
44 print ( GPERF
"%struct-type\n" );
45 print ( GPERF
"struct xmltoken\n" );
46 print ( GPERF
"{\n" );
47 print ( GPERF
" const sal_Char *name; sal_Int32 nToken; \n" );
48 print ( GPERF
"};\n" );
49 print ( GPERF
"%%\n" );
51 print ( HXX
"#ifndef INCLUDED_AUTOGEN_TOKEN_HXX\n" );
52 print ( HXX
"#define INCLUDED_AUTOGEN_TOKEN_HXX\n\n" );
53 print ( HXX
"#include <sal/types.h>\n\n" );
56 foreach( sort(keys(%tokens)) )
59 print( HXX
"const sal_Int32 $tokens{$_} = $i;\n" );
60 print( GPERF
"$_,$tokens{$_}\n" );
62 print ( GPERF
"%%\n" );
63 print ( HXX
"const sal_Int32 XML_TOKEN_COUNT = $i;\n" );
64 print ( HXX
"const sal_Int32 XML_TOKEN_INVALID = -1;\n\n" );
65 print ( HXX
"#endif\n" );