[Ada] Fix iterated element association loop var escaping loop scope
[official-gcc.git] / intl / plural-exp.h
blob2dbb104099efaa0188aa52a910697a95ce10e3d9
1 /* Expression parsing and evaluation for plural form selection.
2 Copyright (C) 2000-2020 Free Software Foundation, Inc.
3 Written by Ulrich Drepper <drepper@cygnus.com>, 2000.
5 This program is free software; you can redistribute it and/or modify it
6 under the terms of the GNU Library General Public License as published
7 by the Free Software Foundation; either version 2, or (at your option)
8 any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301,
18 USA. */
20 #ifndef _PLURAL_EXP_H
21 #define _PLURAL_EXP_H
23 #include <plural-config.h>
25 #ifndef PARAMS
26 # if __STDC__ || defined __GNUC__ || defined __SUNPRO_C || defined __cplusplus || __PROTOTYPES
27 # define PARAMS(args) args
28 # else
29 # define PARAMS(args) ()
30 # endif
31 #endif
33 #ifndef internal_function
34 # define internal_function
35 #endif
37 #ifndef attribute_hidden
38 # define attribute_hidden
39 #endif
42 /* This is the representation of the expressions to determine the
43 plural form. */
44 struct expression
46 int nargs; /* Number of arguments. */
47 enum operator
49 /* Without arguments: */
50 var, /* The variable "n". */
51 num, /* Decimal number. */
52 /* Unary operators: */
53 lnot, /* Logical NOT. */
54 /* Binary operators: */
55 mult, /* Multiplication. */
56 divide, /* Division. */
57 module, /* Modulo operation. */
58 plus, /* Addition. */
59 minus, /* Subtraction. */
60 less_than, /* Comparison. */
61 greater_than, /* Comparison. */
62 less_or_equal, /* Comparison. */
63 greater_or_equal, /* Comparison. */
64 equal, /* Comparison for equality. */
65 not_equal, /* Comparison for inequality. */
66 land, /* Logical AND. */
67 lor, /* Logical OR. */
68 /* Ternary operators: */
69 qmop /* Question mark operator. */
70 } operation;
71 union
73 unsigned long int num; /* Number value for `num'. */
74 struct expression *args[3]; /* Up to three arguments. */
75 } val;
78 /* This is the data structure to pass information to the parser and get
79 the result in a thread-safe way. */
80 struct parse_args
82 const char *cp;
83 struct expression *res;
87 /* Names for the libintl functions are a problem. This source code is used
88 1. in the GNU C Library library,
89 2. in the GNU libintl library,
90 3. in the GNU gettext tools.
91 The function names in each situation must be different, to allow for
92 binary incompatible changes in 'struct expression'. Furthermore,
93 1. in the GNU C Library library, the names have a __ prefix,
94 2.+3. in the GNU libintl library and in the GNU gettext tools, the names
95 must follow ANSI C and not start with __.
96 So we have to distinguish the three cases. */
97 #ifdef _LIBC
98 # define FREE_EXPRESSION __gettext_free_exp
99 # define PLURAL_PARSE __gettextparse
100 # define GERMANIC_PLURAL __gettext_germanic_plural
101 # define EXTRACT_PLURAL_EXPRESSION __gettext_extract_plural
102 #elif defined (IN_LIBINTL)
103 # define FREE_EXPRESSION libintl_gettext_free_exp
104 # define PLURAL_PARSE libintl_gettextparse
105 # define GERMANIC_PLURAL libintl_gettext_germanic_plural
106 # define EXTRACT_PLURAL_EXPRESSION libintl_gettext_extract_plural
107 #else
108 # define FREE_EXPRESSION free_plural_expression
109 # define PLURAL_PARSE parse_plural_expression
110 # define GERMANIC_PLURAL germanic_plural
111 # define EXTRACT_PLURAL_EXPRESSION extract_plural_expression
112 #endif
114 extern void FREE_EXPRESSION PARAMS ((struct expression *exp))
115 internal_function;
116 #ifdef USE_BISON3
117 extern int PLURAL_PARSE PARAMS ((struct parse_args *arg));
118 #else
119 extern int PLURAL_PARSE PARAMS ((void *arg));
120 #endif
121 extern struct expression GERMANIC_PLURAL attribute_hidden;
122 extern void EXTRACT_PLURAL_EXPRESSION PARAMS ((const char *nullentry,
123 struct expression **pluralp,
124 unsigned long int *npluralsp))
125 internal_function;
127 #if !defined (_LIBC) && !defined (IN_LIBINTL)
128 extern unsigned long int plural_eval PARAMS ((struct expression *pexp,
129 unsigned long int n));
130 #endif
132 #endif /* _PLURAL_EXP_H */