source: trunk/flex/tables_shared.h@ 3032

Last change on this file since 3032 was 3031, checked in by bird, 18 years ago

flex 2.5.33.

File size: 5.0 KB
Line 
1#ifdef FLEX_SCANNER
2/*
3dnl tables_shared.h - tables serialization header
4dnl
5dnl Copyright (c) 1990 The Regents of the University of California.
6dnl All rights reserved.
7dnl
8dnl This code is derived from software contributed to Berkeley by
9dnl Vern Paxson.
10dnl
11dnl The United States Government has rights in this work pursuant
12dnl to contract no. DE-AC03-76SF00098 between the United States
13dnl Department of Energy and the University of California.
14dnl
15dnl This file is part of flex.
16dnl
17dnl Redistribution and use in source and binary forms, with or without
18dnl modification, are permitted provided that the following conditions
19dnl are met:
20dnl
21dnl 1. Redistributions of source code must retain the above copyright
22dnl notice, this list of conditions and the following disclaimer.
23dnl 2. Redistributions in binary form must reproduce the above copyright
24dnl notice, this list of conditions and the following disclaimer in the
25dnl documentation and/or other materials provided with the distribution.
26dnl
27dnl Neither the name of the University nor the names of its contributors
28dnl may be used to endorse or promote products derived from this software
29dnl without specific prior written permission.
30dnl
31dnl THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
32dnl IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
33dnl WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
34dnl PURPOSE.
35
36
37dnl
38dnl This file is meant to be included in both the skeleton and the actual
39dnl flex code (hence the name "_shared").
40*/
41#ifndef yyskel_static
42#define yyskel_static static
43#endif
44#else
45#ifndef yyskel_static
46#define yyskel_static
47#endif
48#endif
49
50/* Structures and prototypes for serializing flex tables. The
51 * binary format is documented in the manual.
52 *
53 * Design considerations:
54 *
55 * - The format allows many tables per file.
56 * - The tables can be streamed.
57 * - All data is stored in network byte order.
58 * - We do not hinder future unicode support.
59 * - We can lookup tables by name.
60 */
61
62/** Magic number for serialized format. */
63#ifndef YYTBL_MAGIC
64#define YYTBL_MAGIC 0xF13C57B1
65#endif
66
67/** Calculate (0-7) = number bytes needed to pad n to next 64-bit boundary. */
68#ifndef yypad64
69#define yypad64(n) ((8-((n)%8))%8)
70#endif
71
72
73#ifndef YYTABLES_TYPES
74#define YYTABLES_TYPES
75/** Possible values for td_id field. Each one corresponds to a
76 * scanner table of the same name.
77 */
78enum yytbl_id {
79 YYTD_ID_ACCEPT = 0x01, /**< 1-dim ints */
80 YYTD_ID_BASE = 0x02, /**< 1-dim ints */
81 YYTD_ID_CHK = 0x03, /**< 1-dim ints */
82 YYTD_ID_DEF = 0x04, /**< 1-dim ints */
83 YYTD_ID_EC = 0x05, /**< 1-dim ints */
84 YYTD_ID_META = 0x06, /**< 1-dim ints */
85 YYTD_ID_NUL_TRANS = 0x07, /**< 1-dim ints, maybe indices */
86 YYTD_ID_NXT = 0x08, /**< may be 2 dimensional ints */
87 YYTD_ID_RULE_CAN_MATCH_EOL = 0x09, /**< 1-dim ints */
88 YYTD_ID_START_STATE_LIST = 0x0A, /**< 1-dim indices into trans tbl */
89 YYTD_ID_TRANSITION = 0x0B, /**< structs */
90 YYTD_ID_ACCLIST = 0x0C /**< 1-dim ints */
91};
92
93/** bit flags for t_flags field of struct yytbl_data */
94enum yytbl_flags {
95 /* These first three are mutually exclusive */
96 YYTD_DATA8 = 0x01, /**< data is an array of type flex_int8_t */
97 YYTD_DATA16 = 0x02, /**< data is an array of type flex_int16_t */
98 YYTD_DATA32 = 0x04, /**< data is an array of type flex_int32_t */
99
100 /* These two are mutually exclusive. */
101 YYTD_PTRANS = 0x08, /**< data is a list of indexes of entries
102 into the expanded `yy_transition'
103 array. See notes in manual. */
104 YYTD_STRUCT = 0x10 /**< data consists of yy_trans_info structs */
105};
106
107/* The serialized tables header. */
108struct yytbl_hdr {
109 flex_uint32_t th_magic; /**< Must be 0xF13C57B1 (comes from "Flex Table") */
110 flex_uint32_t th_hsize; /**< Size of this header in bytes. */
111 flex_uint32_t th_ssize; /**< Size of this dataset, in bytes, including header. */
112 flex_uint16_t th_flags; /**< Currently unused, must be 0 */
113 char *th_version; /**< Flex version string. NUL terminated. */
114 char *th_name; /**< The name of this table set. NUL terminated. */
115};
116
117/** A single serialized table */
118struct yytbl_data {
119 flex_uint16_t td_id; /**< enum yytbl_id table identifier */
120 flex_uint16_t td_flags; /**< how to interpret this data */
121 flex_uint32_t td_hilen; /**< num elements in highest dimension array */
122 flex_uint32_t td_lolen; /**< num elements in lowest dimension array */
123 void *td_data; /**< table data */
124};
125#endif
126
127/** Extract corresponding data size_t from td_flags */
128#ifndef YYTDFLAGS2BYTES
129#define YYTDFLAGS2BYTES(td_flags)\
130 (((td_flags) & YYTD_DATA8)\
131 ? sizeof(flex_int8_t)\
132 :(((td_flags) & YYTD_DATA16)\
133 ? sizeof(flex_int16_t)\
134 :sizeof(flex_int32_t)))
135#endif
136
137#ifdef FLEX_SCANNER
138%not-for-header
139#endif
140yyskel_static flex_int32_t yytbl_calc_total_len (const struct yytbl_data *tbl);
141#ifdef FLEX_SCANNER
142%ok-for-header
143#endif
144
145/* vim:set noexpandtab cindent tabstop=8 softtabstop=0 shiftwidth=8 textwidth=0: */
Note: See TracBrowser for help on using the repository browser.