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 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 #define	PEEK_TOKEN	0
35 #define	GET_TOKEN	1
36 
37 #define	NARY	0
38 #define	UNARY	1
39 #define	BINARY	2
40 #define	TRINARY	3
41 
42 #define	T_NULL	0x00000000
43 #define	T_INIT	0x00000001
44 #define	T_EXP	0x00000002
45 #define	T_NUM	0x00000003
46 #define	T_VAR	0x00000004
47 #define	T_CONDC	0x00000005
48 #define	T_CONDQ	0x00000006
49 #define	T_LOR	0x00000007
50 #define	T_LAND	0x00000008
51 #define	T_EQ	0x00000009
52 #define	T_NEQ	0x0000000a
53 #define	T_GT	0x0000000b
54 #define	T_LT	0x0000000c
55 #define	T_GE	0x0000000d
56 #define	T_LE	0x0000000e
57 #define	T_ADD	0x0000000f
58 #define	T_SUB	0x00000010
59 #define	T_MUL	0x00000011
60 #define	T_DIV	0x00000012
61 #define	T_MOD	0x00000013
62 #define	T_LNOT	0x00000014
63 #define	T_LPAR	0x00000015
64 #define	T_RPAR	0x00000016
65 #define	T_ERR	0x00000017
66 
67 #define	GETTYPE(op)	((op) & 0x000fffff)
68 #define	GETPRIO(op)	(((op) & 0x0ff00000) >> 20)
69 #define	GETOPNUM(op)	(((op) & 0xf0000000) >> 28)
70 
71 #define	MAX_STACK_SIZE	128
72 
73 struct expr {
74 	unsigned int	op;		/* operator */
75 	unsigned int	num;	/* T_NUM */
76 	unsigned int	flag;	/* flag for the previous op */
77 	struct expr	*nodes[3];	/* operands */
78 };
79 
80 struct stack {
81 	int	index;
82 	struct expr	**ptr;
83 };
84 
85 #ifdef	__cplusplus
86 }
87 #endif
88 
89 #endif	/* _LIBC_PORT_I18N_PLURAL_PARSER_H */
90