xref: /aosp_15_r20/external/antlr/runtime/C/include/antlr3cyclicdfa.h (revision 16467b971bd3e2009fad32dd79016f2c7e421deb)
1*16467b97STreehugger Robot /// Definition of a cyclic dfa structure such that it can be
2*16467b97STreehugger Robot /// initialized at compile time and have only a single
3*16467b97STreehugger Robot /// runtime function that can deal with all cyclic dfa
4*16467b97STreehugger Robot /// structures and show Java how it is done ;-)
5*16467b97STreehugger Robot ///
6*16467b97STreehugger Robot #ifndef	ANTLR3_CYCLICDFA_H
7*16467b97STreehugger Robot #define	ANTLR3_CYCLICDFA_H
8*16467b97STreehugger Robot 
9*16467b97STreehugger Robot // [The "BSD licence"]
10*16467b97STreehugger Robot // Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC
11*16467b97STreehugger Robot // http://www.temporal-wave.com
12*16467b97STreehugger Robot // http://www.linkedin.com/in/jimidle
13*16467b97STreehugger Robot //
14*16467b97STreehugger Robot // All rights reserved.
15*16467b97STreehugger Robot //
16*16467b97STreehugger Robot // Redistribution and use in source and binary forms, with or without
17*16467b97STreehugger Robot // modification, are permitted provided that the following conditions
18*16467b97STreehugger Robot // are met:
19*16467b97STreehugger Robot // 1. Redistributions of source code must retain the above copyright
20*16467b97STreehugger Robot //    notice, this list of conditions and the following disclaimer.
21*16467b97STreehugger Robot // 2. Redistributions in binary form must reproduce the above copyright
22*16467b97STreehugger Robot //    notice, this list of conditions and the following disclaimer in the
23*16467b97STreehugger Robot //    documentation and/or other materials provided with the distribution.
24*16467b97STreehugger Robot // 3. The name of the author may not be used to endorse or promote products
25*16467b97STreehugger Robot //    derived from this software without specific prior written permission.
26*16467b97STreehugger Robot //
27*16467b97STreehugger Robot // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
28*16467b97STreehugger Robot // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
29*16467b97STreehugger Robot // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
30*16467b97STreehugger Robot // IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
31*16467b97STreehugger Robot // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
32*16467b97STreehugger Robot // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33*16467b97STreehugger Robot // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34*16467b97STreehugger Robot // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35*16467b97STreehugger Robot // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
36*16467b97STreehugger Robot // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37*16467b97STreehugger Robot 
38*16467b97STreehugger Robot #include    <antlr3baserecognizer.h>
39*16467b97STreehugger Robot #include    <antlr3intstream.h>
40*16467b97STreehugger Robot 
41*16467b97STreehugger Robot #ifdef __cplusplus
42*16467b97STreehugger Robot extern "C" {
43*16467b97STreehugger Robot 
44*16467b97STreehugger Robot // If this header file is included as part of a generated recognizer that
45*16467b97STreehugger Robot // is being compiled as if it were C++, and this is Windows, then the const elements
46*16467b97STreehugger Robot // of the structure cause the C++ compiler to (rightly) point out that
47*16467b97STreehugger Robot // there can be no instantiation of the structure because it needs a constructor
48*16467b97STreehugger Robot // that can initialize the data, however these structures are not
49*16467b97STreehugger Robot // useful for C++ as they are pre-generated and static in the recognizer.
50*16467b97STreehugger Robot // So, we turn off those warnings, which are only at /W4 anyway.
51*16467b97STreehugger Robot //
52*16467b97STreehugger Robot #ifdef ANTLR3_WINDOWS
53*16467b97STreehugger Robot #pragma warning	(push)
54*16467b97STreehugger Robot #pragma warning (disable : 4510)
55*16467b97STreehugger Robot #pragma warning (disable : 4512)
56*16467b97STreehugger Robot #pragma warning (disable : 4610)
57*16467b97STreehugger Robot #endif
58*16467b97STreehugger Robot #endif
59*16467b97STreehugger Robot 
60*16467b97STreehugger Robot typedef struct ANTLR3_CYCLIC_DFA_struct
61*16467b97STreehugger Robot {
62*16467b97STreehugger Robot     /// Decision number that a particular static structure
63*16467b97STreehugger Robot     ///  represents.
64*16467b97STreehugger Robot     ///
65*16467b97STreehugger Robot     const ANTLR3_INT32		decisionNumber;
66*16467b97STreehugger Robot 
67*16467b97STreehugger Robot     /// What this decision represents
68*16467b97STreehugger Robot     ///
69*16467b97STreehugger Robot     const pANTLR3_UCHAR		description;
70*16467b97STreehugger Robot 
71*16467b97STreehugger Robot     ANTLR3_INT32			(*specialStateTransition)   (void * ctx, pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_INT_STREAM is, struct ANTLR3_CYCLIC_DFA_struct * dfa, ANTLR3_INT32 s);
72*16467b97STreehugger Robot 
73*16467b97STreehugger Robot     ANTLR3_INT32			(*specialTransition)	    (void * ctx, pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_INT_STREAM is, struct ANTLR3_CYCLIC_DFA_struct * dfa, ANTLR3_INT32 s);
74*16467b97STreehugger Robot 
75*16467b97STreehugger Robot     ANTLR3_INT32			(*predict)					(void * ctx, pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_INT_STREAM is, struct ANTLR3_CYCLIC_DFA_struct * dfa);
76*16467b97STreehugger Robot 
77*16467b97STreehugger Robot     const ANTLR3_INT32		    * const eot;
78*16467b97STreehugger Robot     const ANTLR3_INT32		    * const eof;
79*16467b97STreehugger Robot     const ANTLR3_INT32		    * const min;
80*16467b97STreehugger Robot     const ANTLR3_INT32		    * const max;
81*16467b97STreehugger Robot     const ANTLR3_INT32		    * const accept;
82*16467b97STreehugger Robot     const ANTLR3_INT32		    * const special;
83*16467b97STreehugger Robot     const ANTLR3_INT32			* const * const transition;
84*16467b97STreehugger Robot 
85*16467b97STreehugger Robot }
86*16467b97STreehugger Robot     ANTLR3_CYCLIC_DFA;
87*16467b97STreehugger Robot 
88*16467b97STreehugger Robot typedef ANTLR3_INT32		(*CDFA_SPECIAL_FUNC)   (void * , pANTLR3_BASE_RECOGNIZER , pANTLR3_INT_STREAM , struct ANTLR3_CYCLIC_DFA_struct * , ANTLR3_INT32);
89*16467b97STreehugger Robot 
90*16467b97STreehugger Robot #ifdef __cplusplus
91*16467b97STreehugger Robot }
92*16467b97STreehugger Robot #ifdef ANTLR3_WINDOWS
93*16467b97STreehugger Robot #pragma warning	(pop)
94*16467b97STreehugger Robot #endif
95*16467b97STreehugger Robot #endif
96*16467b97STreehugger Robot 
97*16467b97STreehugger Robot #endif
98