1 /* Unicode CLDR plural rule parser and converter
2 Copyright (C) 2015 Free Software Foundation, Inc.
4 This file was written by Daiki Ueno <ueno@gnu.org>, 2015.
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 #ifndef _CLDR_PLURAL_EXP_H
20 #define _CLDR_PLURAL_EXP_H 1
28 enum cldr_plural_operand
30 CLDR_PLURAL_OPERAND_INTEGER,
31 CLDR_PLURAL_OPERAND_DECIMAL
34 struct cldr_plural_operand_ty
36 enum cldr_plural_operand type;
48 enum cldr_plural_relation
50 CLDR_PLURAL_RELATION_EQUAL,
51 CLDR_PLURAL_RELATION_NOT_EQUAL
54 struct cldr_plural_range_ty
56 struct cldr_plural_operand_ty *start;
57 struct cldr_plural_operand_ty *end;
60 struct cldr_plural_range_list_ty
62 struct cldr_plural_range_ty **items;
67 struct cldr_plural_expression_ty
69 /* 'n', 'i', 'f', 't', 'v', 'w' */
76 struct cldr_plural_relation_ty
78 struct cldr_plural_expression_ty *expression;
79 enum cldr_plural_relation type;
80 struct cldr_plural_range_list_ty *ranges;
83 enum cldr_plural_condition
85 CLDR_PLURAL_CONDITION_AND,
86 CLDR_PLURAL_CONDITION_OR,
87 CLDR_PLURAL_CONDITION_RELATION,
88 CLDR_PLURAL_CONDITION_TRUE,
89 CLDR_PLURAL_CONDITION_FALSE
92 struct cldr_plural_condition_ty
94 enum cldr_plural_condition type;
97 struct cldr_plural_relation_ty *relation;
98 struct cldr_plural_condition_ty *conditions[2];
102 struct cldr_plural_rule_ty
105 struct cldr_plural_condition_ty *condition;
108 struct cldr_plural_rule_list_ty
110 struct cldr_plural_rule_ty **items;
115 struct cldr_plural_parse_args
119 struct cldr_plural_rule_list_ty *result;
123 cldr_plural_range_free (struct cldr_plural_range_ty *range);
125 cldr_plural_range_list_free (struct cldr_plural_range_list_ty *ranges);
127 cldr_plural_condition_free (struct cldr_plural_condition_ty *condition);
129 cldr_plural_relation_free (struct cldr_plural_relation_ty *relation);
131 extern struct cldr_plural_rule_list_ty *
132 cldr_plural_parse (const char *input);
134 cldr_plural_rule_list_free (struct cldr_plural_rule_list_ty *rules);
136 cldr_plural_rule_list_print (struct cldr_plural_rule_list_ty *rules, FILE *fp);
141 #endif /* _CLDR_PLURAL_EXP_H */