xref: /illumos-gate/usr/src/lib/libc/port/i18n/plural_parser.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 2001 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #ifndef	_LIBC_PORT_I18N_PLURAL_PARSER_H
28 #define	_LIBC_PORT_I18N_PLURAL_PARSER_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #define	PEEK_TOKEN	0
37 #define	GET_TOKEN	1
38 
39 #define	NARY	0
40 #define	UNARY	1
41 #define	BINARY	2
42 #define	TRINARY	3
43 
44 #define	T_NULL	0x00000000
45 #define	T_INIT	0x00000001
46 #define	T_EXP	0x00000002
47 #define	T_NUM	0x00000003
48 #define	T_VAR	0x00000004
49 #define	T_CONDC	0x00000005
50 #define	T_CONDQ	0x00000006
51 #define	T_LOR	0x00000007
52 #define	T_LAND	0x00000008
53 #define	T_EQ	0x00000009
54 #define	T_NEQ	0x0000000a
55 #define	T_GT	0x0000000b
56 #define	T_LT	0x0000000c
57 #define	T_GE	0x0000000d
58 #define	T_LE	0x0000000e
59 #define	T_ADD	0x0000000f
60 #define	T_SUB	0x00000010
61 #define	T_MUL	0x00000011
62 #define	T_DIV	0x00000012
63 #define	T_MOD	0x00000013
64 #define	T_LNOT	0x00000014
65 #define	T_LPAR	0x00000015
66 #define	T_RPAR	0x00000016
67 #define	T_ERR	0x00000017
68 
69 #define	GETTYPE(op)	((op) & 0x000fffff)
70 #define	GETPRIO(op)	(((op) & 0x0ff00000) >> 20)
71 #define	GETOPNUM(op)	(((op) & 0xf0000000) >> 28)
72 
73 #define	MAX_STACK_SIZE	128
74 
75 struct expr {
76 	unsigned int	op;		/* operator */
77 	unsigned int	num;	/* T_NUM */
78 	unsigned int	flag;	/* flag for the previous op */
79 	struct expr	*nodes[3];	/* operands */
80 };
81 
82 struct stack {
83 	int	index;
84 	struct expr	**ptr;
85 };
86 
87 #ifdef	__cplusplus
88 }
89 #endif
90 
91 #endif	/* _LIBC_PORT_I18N_PLURAL_PARSER_H */
92