2
2
/* Expression parsing for plural form selection.
3
Copyright (C) 2000, 2001 Free Software Foundation, Inc.
3
Copyright (C) 2000-2001, 2003 Free Software Foundation, Inc.
4
4
Written by Ulrich Drepper <drepper@cygnus.com>, 2000.
6
6
This program is free software; you can redistribute it and/or modify it
30
30
# include <config.h>
33
34
#include <stdlib.h>
35
#include "plural-exp.h"
36
/* Names for the libintl functions are a problem. They must not clash
37
with existing names and they should follow ANSI C. But this source
38
code is also used in GNU C Library where the names have a __
39
prefix. So we have to make a difference here. */
41
# define FREE_EXPRESSION __gettext_free_exp
43
# define FREE_EXPRESSION gettext_free_exp__
44
# define __gettextparse gettextparse__
37
/* The main function generated by the parser is called __gettextparse,
38
but we want it to be called PLURAL_PARSE. */
40
# define __gettextparse PLURAL_PARSE
47
43
#define YYLEX_PARAM &((struct parse_args *) arg)->cp
48
44
#define YYPARSE_PARAM arg
54
50
unsigned long int num;
60
56
/* Prototypes for local functions. */
61
static struct expression *new_exp PARAMS ((int nargs, enum operator op,
62
struct expression * const *args));
63
static inline struct expression *new_exp_0 PARAMS ((enum operator op));
64
static inline struct expression *new_exp_1 PARAMS ((enum operator op,
65
struct expression *right));
66
static struct expression *new_exp_2 PARAMS ((enum operator op,
67
struct expression *left,
68
struct expression *right));
69
static inline struct expression *new_exp_3 PARAMS ((enum operator op,
70
struct expression *bexp,
71
struct expression *tbranch,
72
struct expression *fbranch));
73
static int yylex PARAMS ((YYSTYPE *lval, const char **pexp));
74
static void yyerror PARAMS ((const char *str));
57
static int yylex (YYSTYPE *lval, const char **pexp);
58
static void yyerror (const char *str);
76
60
/* Allocation of expressions. */
78
62
static struct expression *
79
new_exp (nargs, op, args)
82
struct expression * const *args;
63
new_exp (int nargs, enum operator op, struct expression * const *args)
85
66
struct expression *newp;
110
91
static inline struct expression *
92
new_exp_0 (enum operator op)
114
94
return new_exp (0, op, NULL);
117
97
static inline struct expression *
118
new_exp_1 (op, right)
120
struct expression *right;
98
new_exp_1 (enum operator op, struct expression *right)
122
100
struct expression *args[1];
128
106
static struct expression *
129
new_exp_2 (op, left, right)
131
struct expression *left;
132
struct expression *right;
107
new_exp_2 (enum operator op, struct expression *left, struct expression *right)
134
109
struct expression *args[2];
141
116
static inline struct expression *
142
new_exp_3 (op, bexp, tbranch, fbranch)
144
struct expression *bexp;
145
struct expression *tbranch;
146
struct expression *fbranch;
117
new_exp_3 (enum operator op, struct expression *bexp,
118
struct expression *tbranch, struct expression *fbranch)
148
120
struct expression *args[3];