Path: blob/devel/ElmerGUI/netgen/libsrc/include/FlexLexer.h
3206 views
// $Header: /cvs/netgen/netgen/libsrc/include/FlexLexer.h,v 1.3 2008/03/31 14:20:27 wabro Exp $12// FlexLexer.h -- define interfaces for lexical analyzer classes generated3// by flex45// Copyright (c) 1993 The Regents of the University of California.6// All rights reserved.7//8// This code is derived from software contributed to Berkeley by9// Kent Williams and Tom Epperly.10//11// Redistribution and use in source and binary forms are permitted provided12// that: (1) source distributions retain this entire copyright notice and13// comment, and (2) distributions including binaries display the following14// acknowledgement: ``This product includes software developed by the15// University of California, Berkeley and its contributors'' in the16// documentation or other materials provided with the distribution and in17// all advertising materials mentioning features or use of this software.18// Neither the name of the University nor the names of its contributors may19// be used to endorse or promote products derived from this software without20// specific prior written permission.21// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED22// WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF23// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.2425// This file defines FlexLexer, an abstract class which specifies the26// external interface provided to flex C++ lexer objects, and yyFlexLexer,27// which defines a particular lexer class.28//29// If you want to create multiple lexer classes, you use the -P flag30// to rename each yyFlexLexer to some other xxFlexLexer. You then31// include <FlexLexer.h> in your other sources once per lexer class:32//33// #undef yyFlexLexer34// #define yyFlexLexer xxFlexLexer35// #include <FlexLexer.h>36//37// #undef yyFlexLexer38// #define yyFlexLexer zzFlexLexer39// #include <FlexLexer.h>40// ...4142#ifndef __FLEX_LEXER_H43// Never included before - need to define base class.44#define __FLEX_LEXER_H454647extern "C++" {48struct yy_buffer_state;49typedef int yy_state_type;5051class FlexLexer {52public:53virtual ~FlexLexer() { }5455const char* YYText() { return yytext; }56int YYLeng() { return yyleng; }5758virtual void59yy_switch_to_buffer( struct yy_buffer_state* new_buffer ) = 0;60virtual struct yy_buffer_state*61yy_create_buffer( istream* s, int size ) = 0;62virtual void yy_delete_buffer( struct yy_buffer_state* b ) = 0;63virtual void yyrestart( istream* s ) = 0;6465virtual int yylex() = 0;6667// Call yylex with new input/output sources.68int yylex( istream* new_in, ostream* new_out = 0 )69{70switch_streams( new_in, new_out );71return yylex();72}7374// Switch to new input/output streams. A nil stream pointer75// indicates "keep the current one".76virtual void switch_streams( istream* new_in = 0,77ostream* new_out = 0 ) = 0;7879int lineno() const { return yylineno; }8081int debug() const { return yy_flex_debug; }82void set_debug( int flag ) { yy_flex_debug = flag; }8384protected:85char* yytext;86int yyleng;87int yylineno; // only maintained if you use %option yylineno88int yy_flex_debug; // only has effect with -d or "%option debug"89};9091}92#endif9394#if defined(yyFlexLexer) || ! defined(yyFlexLexerOnce)95// Either this is the first time through (yyFlexLexerOnce not defined),96// or this is a repeated include to define a different flavor of97// yyFlexLexer, as discussed in the flex man page.98#define yyFlexLexerOnce99100class yyFlexLexer : public FlexLexer {101public:102// arg_yyin and arg_yyout default to the cin and cout, but we103// only make that assignment when initializing in yylex().104yyFlexLexer( istream* arg_yyin = 0, ostream* arg_yyout = 0 );105106virtual ~yyFlexLexer();107108void yy_switch_to_buffer( struct yy_buffer_state* new_buffer );109struct yy_buffer_state* yy_create_buffer( istream* s, int size );110void yy_delete_buffer( struct yy_buffer_state* b );111void yyrestart( istream* s );112113virtual int yylex();114virtual void switch_streams( istream* new_in, ostream* new_out );115116protected:117virtual int LexerInput( char* buf, int max_size );118virtual void LexerOutput( const char* buf, int size );119virtual void LexerError( const char* msg );120121void yyunput( int c, char* buf_ptr );122int yyinput();123124void yy_load_buffer_state();125void yy_init_buffer( struct yy_buffer_state* b, istream* s );126void yy_flush_buffer( struct yy_buffer_state* b );127128int yy_start_stack_ptr;129int yy_start_stack_depth;130int* yy_start_stack;131132void yy_push_state( int new_state );133void yy_pop_state();134int yy_top_state();135136yy_state_type yy_get_previous_state();137yy_state_type yy_try_NUL_trans( yy_state_type current_state );138int yy_get_next_buffer();139140istream* yyin; // input source for default LexerInput141ostream* yyout; // output sink for default LexerOutput142143struct yy_buffer_state* yy_current_buffer;144145// yy_hold_char holds the character lost when yytext is formed.146char yy_hold_char;147148// Number of characters read into yy_ch_buf.149int yy_n_chars;150151// Points to current character in buffer.152char* yy_c_buf_p;153154int yy_init; // whether we need to initialize155int yy_start; // start state number156157// Flag which is used to allow yywrap()'s to do buffer switches158// instead of setting up a fresh yyin. A bit of a hack ...159int yy_did_buffer_switch_on_eof;160161// The following are not always needed, but may be depending162// on use of certain flex features (like REJECT or yymore()).163164yy_state_type yy_last_accepting_state;165char* yy_last_accepting_cpos;166167yy_state_type* yy_state_buf;168yy_state_type* yy_state_ptr;169170char* yy_full_match;171int* yy_full_state;172int yy_full_lp;173174int yy_lp;175int yy_looking_for_trail_begin;176177int yy_more_flag;178int yy_more_len;179int yy_more_offset;180int yy_prev_more_offset;181};182183#endif184185186