Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

plural-exp.h

00001 /* Expression parsing and evaluation for plural form selection.
00002    Copyright (C) 2000, 2001 Free Software Foundation, Inc.
00003    Written by Ulrich Drepper <drepper@cygnus.com>, 2000.
00004 
00005    This program is free software; you can redistribute it and/or modify it
00006    under the terms of the GNU Library General Public License as published
00007    by the Free Software Foundation; either version 2, or (at your option)
00008    any later version.
00009 
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public
00016    License along with this program; if not, write to the Free Software
00017    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
00018    USA.  */
00019 
00020 #ifndef _PLURAL_EXP_H
00021 #define _PLURAL_EXP_H
00022 
00023 #ifndef PARAMS
00024 # if __STDC__ || defined __GNUC__ || defined __SUNPRO_C || defined __cplusplus || __PROTOTYPES
00025 #  define PARAMS(args) args
00026 # else
00027 #  define PARAMS(args) ()
00028 # endif
00029 #endif
00030 
00031 #ifndef internal_function
00032 # define internal_function
00033 #endif
00034 
00035 
00036 /* This is the representation of the expressions to determine the
00037    plural form.  */
00038 struct expression
00039 {
00040   int nargs;                    /* Number of arguments.  */
00041   enum operator
00042   {
00043     /* Without arguments:  */
00044     var,                        /* The variable "n".  */
00045     num,                        /* Decimal number.  */
00046     /* Unary operators:  */
00047     lnot,                       /* Logical NOT.  */
00048     /* Binary operators:  */
00049     mult,                       /* Multiplication.  */
00050     divide,                     /* Division.  */
00051     module,                     /* Modulo operation.  */
00052     plus,                       /* Addition.  */
00053     minus,                      /* Subtraction.  */
00054     less_than,                  /* Comparison.  */
00055     greater_than,               /* Comparison.  */
00056     less_or_equal,              /* Comparison.  */
00057     greater_or_equal,           /* Comparison.  */
00058     equal,                      /* Comparison for equality.  */
00059     not_equal,                  /* Comparison for inequality.  */
00060     land,                       /* Logical AND.  */
00061     lor,                        /* Logical OR.  */
00062     /* Ternary operators:  */
00063     qmop                        /* Question mark operator.  */
00064   } operation;
00065   union
00066   {
00067     unsigned long int num;      /* Number value for `num'.  */
00068     struct expression *args[3]; /* Up to three arguments.  */
00069   } val;
00070 };
00071 
00072 /* This is the data structure to pass information to the parser and get
00073    the result in a thread-safe way.  */
00074 struct parse_args
00075 {
00076   const char *cp;
00077   struct expression *res;
00078 };
00079 
00080 
00081 /* Names for the libintl functions are a problem.  This source code is used
00082    1. in the GNU C Library library,
00083    2. in the GNU libintl library,
00084    3. in the GNU gettext tools.
00085    The function names in each situation must be different, to allow for
00086    binary incompatible changes in 'struct expression'.  Furthermore,
00087    1. in the GNU C Library library, the names have a __ prefix,
00088    2.+3. in the GNU libintl library and in the GNU gettext tools, the names
00089          must follow ANSI C and not start with __.
00090    So we have to distinguish the three cases.  */
00091 #ifdef _LIBC
00092 # define FREE_EXPRESSION __gettext_free_exp
00093 # define PLURAL_PARSE __gettextparse
00094 # define GERMANIC_PLURAL __gettext_germanic_plural
00095 # define EXTRACT_PLURAL_EXPRESSION __gettext_extract_plural
00096 #elif defined (IN_LIBINTL)
00097 # define FREE_EXPRESSION gettext_free_exp__
00098 # define PLURAL_PARSE gettextparse__
00099 # define GERMANIC_PLURAL gettext_germanic_plural__
00100 # define EXTRACT_PLURAL_EXPRESSION gettext_extract_plural__
00101 #else
00102 # define FREE_EXPRESSION free_plural_expression
00103 # define PLURAL_PARSE parse_plural_expression
00104 # define GERMANIC_PLURAL germanic_plural
00105 # define EXTRACT_PLURAL_EXPRESSION extract_plural_expression
00106 #endif
00107 
00108 extern void FREE_EXPRESSION PARAMS ((struct expression *exp))
00109      internal_function;
00110 extern int PLURAL_PARSE PARAMS ((void *arg));
00111 extern struct expression GERMANIC_PLURAL;
00112 extern void EXTRACT_PLURAL_EXPRESSION PARAMS ((const char *nullentry,
00113                                                struct expression **pluralp,
00114                                                unsigned long int *npluralsp))
00115      internal_function;
00116 
00117 #if !defined (_LIBC) && !defined (IN_LIBINTL)
00118 extern unsigned long int plural_eval PARAMS ((struct expression *pexp,
00119                                               unsigned long int n));
00120 #endif
00121 
00122 #endif /* _PLURAL_EXP_H */

Generated on Sun Feb 16 23:39:49 2003 for FreeLCD by doxygen1.2.18