1228072Sbapt#ifdef FLEX_SCANNER
2228072Sbapt/*
3228072Sbaptdnl  tables_shared.h - tables serialization header
4228072Sbaptdnl
5228072Sbaptdnl  Copyright (c) 1990 The Regents of the University of California.
6228072Sbaptdnl  All rights reserved.
7228072Sbaptdnl
8228072Sbaptdnl  This code is derived from software contributed to Berkeley by
9228072Sbaptdnl  Vern Paxson.
10228072Sbaptdnl
11228072Sbaptdnl  The United States Government has rights in this work pursuant
12228072Sbaptdnl  to contract no. DE-AC03-76SF00098 between the United States
13228072Sbaptdnl  Department of Energy and the University of California.
14228072Sbaptdnl
15228072Sbaptdnl  This file is part of flex.
16228072Sbaptdnl
17228072Sbaptdnl  Redistribution and use in source and binary forms, with or without
18228072Sbaptdnl  modification, are permitted provided that the following conditions
19228072Sbaptdnl  are met:
20228072Sbaptdnl
21228072Sbaptdnl  1. Redistributions of source code must retain the above copyright
22228072Sbaptdnl     notice, this list of conditions and the following disclaimer.
23228072Sbaptdnl  2. Redistributions in binary form must reproduce the above copyright
24228072Sbaptdnl     notice, this list of conditions and the following disclaimer in the
25228072Sbaptdnl     documentation and/or other materials provided with the distribution.
26228072Sbaptdnl
27228072Sbaptdnl  Neither the name of the University nor the names of its contributors
28228072Sbaptdnl  may be used to endorse or promote products derived from this software
29228072Sbaptdnl  without specific prior written permission.
30228072Sbaptdnl
31228072Sbaptdnl  THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
32228072Sbaptdnl  IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
33228072Sbaptdnl  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
34228072Sbaptdnl  PURPOSE.
35228072Sbapt
36228072Sbaptdnl
37228072Sbaptdnl  This file is meant to be included in both the skeleton and the actual
38228072Sbaptdnl  flex code (hence the name "_shared").
39228072Sbapt*/
40228072Sbapt#ifndef yyskel_static
41228072Sbapt#define yyskel_static static
42228072Sbapt#endif
43228072Sbapt#else
44228072Sbapt#ifndef yyskel_static
45228072Sbapt#define yyskel_static
46228072Sbapt#endif
47228072Sbapt#endif
48228072Sbapt
49228072Sbapt/* Structures and prototypes for serializing flex tables.  The
50228072Sbapt * binary format is documented in the manual.
51228072Sbapt *
52228072Sbapt * Design considerations:
53228072Sbapt *
54228072Sbapt *  -  The format allows many tables per file.
55228072Sbapt *  -  The tables can be streamed.
56228072Sbapt *  -  All data is stored in network byte order.
57228072Sbapt *  -  We do not hinder future unicode support.
58228072Sbapt *  -  We can lookup tables by name.
59228072Sbapt */
60228072Sbapt
61228072Sbapt/** Magic number for serialized format. */
62228072Sbapt#ifndef YYTBL_MAGIC
63228072Sbapt#define YYTBL_MAGIC 0xF13C57B1
64228072Sbapt#endif
65228072Sbapt
66228072Sbapt/** Calculate (0-7) = number bytes needed to pad n to next 64-bit boundary. */
67228072Sbapt#ifndef yypad64
68228072Sbapt#define yypad64(n) ((8-((n)%8))%8)
69228072Sbapt#endif
70228072Sbapt
71228072Sbapt
72228072Sbapt#ifndef YYTABLES_TYPES
73228072Sbapt#define YYTABLES_TYPES
74228072Sbapt/** Possible values for td_id field. Each one corresponds to a
75228072Sbapt *  scanner table of the same name.
76228072Sbapt */
77228072Sbaptenum yytbl_id {
78228072Sbapt	YYTD_ID_ACCEPT = 0x01,		/**< 1-dim ints */
79228072Sbapt	YYTD_ID_BASE = 0x02,		/**< 1-dim ints */
80228072Sbapt	YYTD_ID_CHK = 0x03,		/**< 1-dim ints */
81228072Sbapt	YYTD_ID_DEF = 0x04,		/**< 1-dim ints */
82228072Sbapt	YYTD_ID_EC = 0x05,		/**< 1-dim ints */
83228072Sbapt	YYTD_ID_META = 0x06,		/**< 1-dim ints */
84228072Sbapt	YYTD_ID_NUL_TRANS = 0x07,	/**< 1-dim ints, maybe indices */
85228072Sbapt	YYTD_ID_NXT = 0x08,		/**< may be 2 dimensional ints */
86228072Sbapt	YYTD_ID_RULE_CAN_MATCH_EOL = 0x09, /**< 1-dim ints */
87228072Sbapt	YYTD_ID_START_STATE_LIST = 0x0A,	/**< 1-dim indices into trans tbl  */
88228072Sbapt	YYTD_ID_TRANSITION = 0x0B,	/**< structs */
89228072Sbapt	YYTD_ID_ACCLIST = 0x0C		/**< 1-dim ints */
90228072Sbapt};
91228072Sbapt
92228072Sbapt/** bit flags for t_flags field of struct yytbl_data */
93228072Sbaptenum yytbl_flags {
94228072Sbapt	/* These first three are mutually exclusive */
95228072Sbapt	YYTD_DATA8 = 0x01,   /**< data is an array of type flex_int8_t */
96228072Sbapt	YYTD_DATA16 = 0x02,  /**< data is an array of type flex_int16_t */
97228072Sbapt	YYTD_DATA32 = 0x04,  /**< data is an array of type flex_int32_t */
98228072Sbapt
99228072Sbapt	/* These two are mutually exclusive. */
100228072Sbapt	YYTD_PTRANS = 0x08,  /**< data is a list of indexes of entries
101228072Sbapt                                 into the expanded `yy_transition'
102228072Sbapt                                 array. See notes in manual. */
103228072Sbapt	YYTD_STRUCT = 0x10  /**< data consists of yy_trans_info structs */
104228072Sbapt};
105228072Sbapt
106228072Sbapt/* The serialized tables header. */
107228072Sbaptstruct yytbl_hdr {
108228072Sbapt	flex_uint32_t th_magic;  /**< Must be 0xF13C57B1 (comes from "Flex Table") */
109228072Sbapt	flex_uint32_t th_hsize;  /**< Size of this header in bytes. */
110228072Sbapt	flex_uint32_t th_ssize;  /**< Size of this dataset, in bytes, including header. */
111228072Sbapt	flex_uint16_t th_flags;  /**< Currently unused, must be 0 */
112228072Sbapt	char   *th_version; /**< Flex version string. NUL terminated. */
113228072Sbapt	char   *th_name;    /**< The name of this table set. NUL terminated. */
114228072Sbapt};
115228072Sbapt
116228072Sbapt/** A single serialized table */
117228072Sbaptstruct yytbl_data {
118228072Sbapt	flex_uint16_t td_id;      /**< enum yytbl_id table identifier */
119228072Sbapt	flex_uint16_t td_flags;   /**< how to interpret this data */
120228072Sbapt	flex_uint32_t td_hilen;   /**< num elements in highest dimension array */
121228072Sbapt	flex_uint32_t td_lolen;   /**< num elements in lowest dimension array */
122228072Sbapt	void   *td_data;     /**< table data */
123228072Sbapt};
124228072Sbapt#endif
125228072Sbapt
126228072Sbapt/** Extract corresponding data size_t from td_flags */
127228072Sbapt#ifndef YYTDFLAGS2BYTES
128228072Sbapt#define YYTDFLAGS2BYTES(td_flags)\
129228072Sbapt        (((td_flags) & YYTD_DATA8)\
130228072Sbapt            ? sizeof(flex_int8_t)\
131228072Sbapt            :(((td_flags) & YYTD_DATA16)\
132228072Sbapt                ? sizeof(flex_int16_t)\
133228072Sbapt                :sizeof(flex_int32_t)))
134228072Sbapt#endif
135228072Sbapt
136228072Sbapt#ifdef FLEX_SCANNER
137228072Sbapt%not-for-header
138228072Sbapt#endif
139228072Sbaptyyskel_static flex_int32_t yytbl_calc_total_len (const struct yytbl_data *tbl);
140228072Sbapt#ifdef FLEX_SCANNER
141228072Sbapt%ok-for-header
142228072Sbapt#endif
143228072Sbapt
144228072Sbapt/* vim:set noexpandtab cindent tabstop=8 softtabstop=0 shiftwidth=8 textwidth=0: */
145