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