amd64: Copy MPTable PCI interrput routing code from i386
[dragonfly.git] / usr.bin / lex / FlexLexer.h
blob1d42db65d4b77ba2e32e998376b3f20d007fbbaa
1 // $Header: /home/daffy/u0/vern/flex/RCS/FlexLexer.h,v 1.19 96/05/25 20:43:02 vern Exp $
2 // $FreeBSD: src/usr.bin/lex/FlexLexer.h,v 1.4 2004/03/11 10:43:35 josef Exp $
3 // $DragonFly: src/usr.bin/lex/FlexLexer.h,v 1.3 2005/08/18 17:11:09 joerg Exp $
5 // FlexLexer.h -- define interfaces for lexical analyzer classes generated
6 // by flex
8 // Copyright (c) 1993 The Regents of the University of California.
9 // All rights reserved.
11 // This code is derived from software contributed to Berkeley by
12 // Kent Williams and Tom Epperly.
14 // Redistribution and use in source and binary forms are permitted provided
15 // that: (1) source distributions retain this entire copyright notice and
16 // comment, and (2) distributions including binaries display the following
17 // acknowledgement: ``This product includes software developed by the
18 // University of California, Berkeley and its contributors'' in the
19 // documentation or other materials provided with the distribution and in
20 // all advertising materials mentioning features or use of this software.
21 // Neither the name of the University nor the names of its contributors may
22 // be used to endorse or promote products derived from this software without
23 // specific prior written permission.
24 // THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
25 // WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
26 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
28 // This file defines FlexLexer, an abstract class which specifies the
29 // external interface provided to flex C++ lexer objects, and yyFlexLexer,
30 // which defines a particular lexer class.
32 // If you want to create multiple lexer classes, you use the -P flag
33 // to rename each yyFlexLexer to some other xxFlexLexer. You then
34 // include <FlexLexer.h> in your other sources once per lexer class:
36 // #undef yyFlexLexer
37 // #define yyFlexLexer xxFlexLexer
38 // #include <FlexLexer.h>
40 // #undef yyFlexLexer
41 // #define yyFlexLexer zzFlexLexer
42 // #include <FlexLexer.h>
43 // ...
45 #ifndef __FLEX_LEXER_H
46 // Never included before - need to define base class.
47 #define __FLEX_LEXER_H
48 #include <iostream>
50 extern "C++" {
52 struct yy_buffer_state;
53 typedef int yy_state_type;
55 class FlexLexer {
56 public:
57 virtual ~FlexLexer() { }
59 const char* YYText() { return yytext; }
60 int YYLeng() { return yyleng; }
62 virtual void
63 yy_switch_to_buffer( struct yy_buffer_state* new_buffer ) = 0;
64 virtual struct yy_buffer_state*
65 yy_create_buffer( std::istream* s, int size ) = 0;
66 virtual void yy_delete_buffer( struct yy_buffer_state* b ) = 0;
67 virtual void yyrestart( std::istream* s ) = 0;
69 virtual int yylex() = 0;
71 // Call yylex with new input/output sources.
72 int yylex( std::istream* new_in, std::ostream* new_out = 0 )
74 switch_streams( new_in, new_out );
75 return yylex();
78 // Switch to new input/output streams. A nil stream pointer
79 // indicates "keep the current one".
80 virtual void switch_streams( std::istream* new_in = 0,
81 std::ostream* new_out = 0 ) = 0;
83 int lineno() const { return yylineno; }
85 int debug() const { return yy_flex_debug; }
86 void set_debug( int flag ) { yy_flex_debug = flag; }
88 protected:
89 char* yytext;
90 int yyleng;
91 int yylineno; // only maintained if you use %option yylineno
92 int yy_flex_debug; // only has effect with -d or "%option debug"
96 #endif
98 #if defined(yyFlexLexer) || ! defined(yyFlexLexerOnce)
99 // Either this is the first time through (yyFlexLexerOnce not defined),
100 // or this is a repeated include to define a different flavor of
101 // yyFlexLexer, as discussed in the flex man page.
102 #define yyFlexLexerOnce
104 class yyFlexLexer : public FlexLexer {
105 public:
106 // arg_yyin and arg_yyout default to the cin and cout, but we
107 // only make that assignment when initializing in yylex().
108 yyFlexLexer( std::istream* arg_yyin = 0, std::ostream* arg_yyout = 0 );
110 virtual ~yyFlexLexer();
112 void yy_switch_to_buffer( struct yy_buffer_state* new_buffer );
113 struct yy_buffer_state* yy_create_buffer( std::istream* s, int size );
114 void yy_delete_buffer( struct yy_buffer_state* b );
115 void yyrestart( std::istream* s );
117 virtual int yylex();
118 virtual void switch_streams( std::istream* new_in, std::ostream* new_out );
120 protected:
121 virtual int LexerInput( char* buf, int max_size );
122 virtual void LexerOutput( const char* buf, int size );
123 virtual void LexerError( const char* msg );
125 void yyunput( int c, char* buf_ptr );
126 int yyinput();
128 void yy_load_buffer_state();
129 void yy_init_buffer( struct yy_buffer_state* b, std::istream* s );
130 void yy_flush_buffer( struct yy_buffer_state* b );
132 int yy_start_stack_ptr;
133 int yy_start_stack_depth;
134 int* yy_start_stack;
136 void yy_push_state( int new_state );
137 void yy_pop_state();
138 int yy_top_state();
140 yy_state_type yy_get_previous_state();
141 yy_state_type yy_try_NUL_trans( yy_state_type current_state );
142 int yy_get_next_buffer();
144 std::istream* yyin; // input source for default LexerInput
145 std::ostream* yyout; // output sink for default LexerOutput
147 struct yy_buffer_state* yy_current_buffer;
149 // yy_hold_char holds the character lost when yytext is formed.
150 char yy_hold_char;
152 // Number of characters read into yy_ch_buf.
153 int yy_n_chars;
155 // Points to current character in buffer.
156 char* yy_c_buf_p;
158 int yy_init; // whether we need to initialize
159 int yy_start; // start state number
161 // Flag which is used to allow yywrap()'s to do buffer switches
162 // instead of setting up a fresh yyin. A bit of a hack ...
163 int yy_did_buffer_switch_on_eof;
165 // The following are not always needed, but may be depending
166 // on use of certain flex features (like REJECT or yymore()).
168 yy_state_type yy_last_accepting_state;
169 char* yy_last_accepting_cpos;
171 yy_state_type* yy_state_buf;
172 yy_state_type* yy_state_ptr;
174 char* yy_full_match;
175 int* yy_full_state;
176 int yy_full_lp;
178 int yy_lp;
179 int yy_looking_for_trail_begin;
181 int yy_more_flag;
182 int yy_more_len;
183 int yy_more_offset;
184 int yy_prev_more_offset;
187 #endif