+2001-03-12 Bruno Haible <haible@clisp.cons.org>
+
+ * gettextP.h (struct expression): Add operators less_than,
+ greater_than, less_or_equal, greater_or_equal.
+ * plural.y ('<', '>', LE, GE): New operators.
+ (exp): Add rules with these operators.
+ (FREE_EXPRESSION): Recognize these operators.
+ (yylex): Don't skip "\\n". Recognize '<', '>', LE, GE operators.
+ * dcigettext.c (plural_eval): Recognize these operators.
+
2001-03-10 Bruno Haible <haible@clisp.cons.org>
* Makefile.in (libintl.la): Pass -liconv and flag -no-undefined.
case minus:
return (plural_eval (pexp->val.args2.left, n)
- plural_eval (pexp->val.args2.right, n));
+ case less_than:
+ return (plural_eval (pexp->val.args2.left, n)
+ < plural_eval (pexp->val.args2.right, n));
+ case greater_than:
+ return (plural_eval (pexp->val.args2.left, n)
+ > plural_eval (pexp->val.args2.right, n));
+ case less_or_equal:
+ return (plural_eval (pexp->val.args2.left, n)
+ <= plural_eval (pexp->val.args2.right, n));
+ case greater_or_equal:
+ return (plural_eval (pexp->val.args2.left, n)
+ >= plural_eval (pexp->val.args2.right, n));
case equal:
return (plural_eval (pexp->val.args2.left, n)
== plural_eval (pexp->val.args2.right, n));
module, /* Module operation. */
plus, /* Addition. */
minus, /* Subtraction. */
- equal, /* Comparision for equality. */
- not_equal, /* Comparision for inequality. */
+ less_than, /* Comparison. */
+ greater_than, /* Comparison. */
+ less_or_equal, /* Comparison. */
+ greater_or_equal, /* Comparison. */
+ equal, /* Comparison for equality. */
+ not_equal, /* Comparison for inequality. */
land, /* Logical AND. */
lor, /* Logical OR. */
qmop /* Question mark operator. */
static void yyerror PARAMS ((const char *str));
%}
-%left '?'
-%left '|'
-%left '&'
-%left '=', '!'
-%left '+', '-'
-%left '*', '/', '%'
+/* This declares that all operators are left-associative, and that the
+ precedence order is the same as in C. There is no unary minus. */
+%left '?' /* ? */
+%left '|' /* || */
+%left '&' /* && */
+%left '=', '!' /* == != */
+%nonassoc '<', '>', LE, GE /* < > <= >= */
+%left '+', '-' /* + - */
+%left '*', '/', '%' /* * / % */
+
%token <num> NUMBER
%type <exp> exp
if (($$ = new_exp_2 (not_equal, $1, $3)) == NULL)
YYABORT
}
+ | exp '<' exp
+ {
+ if (($$ = new_exp_2 (less_than, $1, $3)) == NULL)
+ YYABORT
+ }
+ | exp '>' exp
+ {
+ if (($$ = new_exp_2 (greater_than, $1, $3)) == NULL)
+ YYABORT
+ }
+ | exp LE exp
+ {
+ if (($$ = new_exp_2 (less_or_equal, $1, $3)) == NULL)
+ YYABORT
+ }
+ | exp GE exp
+ {
+ if (($$ = new_exp_2 (greater_or_equal, $1, $3)) == NULL)
+ YYABORT
+ }
| exp '+' exp
{
if (($$ = new_exp_2 (plus, $1, $3)) == NULL)
case module:
case plus:
case minus:
+ case less_than:
+ case greater_than:
+ case less_or_equal:
+ case greater_or_equal:
case equal:
case not_equal:
case land:
while (1)
{
- if (exp[0] == '\\' && exp[1] == '\n')
- {
- exp += 2;
- continue;
- }
-
if (exp[0] == '\0')
{
*pexp = exp;
result = YYERRCODE;
break;
+ case '<':
+ if (exp[0] == '=')
+ {
+ ++exp;
+ result = LE;
+ }
+ break;
+
+ case '>':
+ if (exp[0] == '=')
+ {
+ ++exp;
+ result = GE;
+ }
+ break;
+
case 'n':
case '*':
case '/':