| 1 | // -*-C++-*-
|
|---|
| 2 | // FlexLexer.h -- define interfaces for lexical analyzer classes generated
|
|---|
| 3 | // by flex
|
|---|
| 4 |
|
|---|
| 5 | // 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 by
|
|---|
| 9 | // Kent Williams and Tom Epperly.
|
|---|
| 10 | //
|
|---|
| 11 | // Redistribution and use in source and binary forms, with or without
|
|---|
| 12 | // modification, are permitted provided that the following conditions
|
|---|
| 13 | // are met:
|
|---|
| 14 |
|
|---|
| 15 | // 1. Redistributions of source code must retain the above copyright
|
|---|
| 16 | // notice, this list of conditions and the following disclaimer.
|
|---|
| 17 | // 2. Redistributions in binary form must reproduce the above copyright
|
|---|
| 18 | // notice, this list of conditions and the following disclaimer in the
|
|---|
| 19 | // documentation and/or other materials provided with the distribution.
|
|---|
| 20 |
|
|---|
| 21 | // Neither the name of the University nor the names of its contributors
|
|---|
| 22 | // may be used to endorse or promote products derived from this software
|
|---|
| 23 | // without specific prior written permission.
|
|---|
| 24 |
|
|---|
| 25 | // THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
|---|
| 26 | // IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
|---|
| 27 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|---|
| 28 | // PURPOSE.
|
|---|
| 29 |
|
|---|
| 30 | // This file defines FlexLexer, an abstract class which specifies the
|
|---|
| 31 | // external interface provided to flex C++ lexer objects, and yyFlexLexer,
|
|---|
| 32 | // which defines a particular lexer class.
|
|---|
| 33 | //
|
|---|
| 34 | // If you want to create multiple lexer classes, you use the -P flag
|
|---|
| 35 | // to rename each yyFlexLexer to some other xxFlexLexer. You then
|
|---|
| 36 | // include <FlexLexer.h> in your other sources once per lexer class:
|
|---|
| 37 | //
|
|---|
| 38 | // #undef yyFlexLexer
|
|---|
| 39 | // #define yyFlexLexer xxFlexLexer
|
|---|
| 40 | // #include <FlexLexer.h>
|
|---|
| 41 | //
|
|---|
| 42 | // #undef yyFlexLexer
|
|---|
| 43 | // #define yyFlexLexer zzFlexLexer
|
|---|
| 44 | // #include <FlexLexer.h>
|
|---|
| 45 | // ...
|
|---|
| 46 |
|
|---|
| 47 | #ifndef __FLEX_LEXER_H
|
|---|
| 48 | // Never included before - need to define base class.
|
|---|
| 49 | #define __FLEX_LEXER_H
|
|---|
| 50 |
|
|---|
| 51 | #include <iostream>
|
|---|
| 52 | # ifndef FLEX_STD
|
|---|
| 53 | # define FLEX_STD std::
|
|---|
| 54 | # endif
|
|---|
| 55 |
|
|---|
| 56 | extern "C++" {
|
|---|
| 57 |
|
|---|
| 58 | struct yy_buffer_state;
|
|---|
| 59 | typedef int yy_state_type;
|
|---|
| 60 |
|
|---|
| 61 | class FlexLexer {
|
|---|
| 62 | public:
|
|---|
| 63 | virtual ~FlexLexer() { }
|
|---|
| 64 |
|
|---|
| 65 | const char* YYText() { return yytext; }
|
|---|
| 66 | int YYLeng() { return yyleng; }
|
|---|
| 67 |
|
|---|
| 68 | virtual void
|
|---|
| 69 | yy_switch_to_buffer( struct yy_buffer_state* new_buffer ) = 0;
|
|---|
| 70 | virtual struct yy_buffer_state*
|
|---|
| 71 | yy_create_buffer( FLEX_STD istream* s, int size ) = 0;
|
|---|
| 72 | virtual void yy_delete_buffer( struct yy_buffer_state* b ) = 0;
|
|---|
| 73 | virtual void yyrestart( FLEX_STD istream* s ) = 0;
|
|---|
| 74 |
|
|---|
| 75 | virtual int yylex() = 0;
|
|---|
| 76 |
|
|---|
| 77 | // Call yylex with new input/output sources.
|
|---|
| 78 | int yylex( FLEX_STD istream* new_in, FLEX_STD ostream* new_out = 0 )
|
|---|
| 79 | {
|
|---|
| 80 | switch_streams( new_in, new_out );
|
|---|
| 81 | return yylex();
|
|---|
| 82 | }
|
|---|
| 83 |
|
|---|
| 84 | // Switch to new input/output streams. A nil stream pointer
|
|---|
| 85 | // indicates "keep the current one".
|
|---|
| 86 | virtual void switch_streams( FLEX_STD istream* new_in = 0,
|
|---|
| 87 | FLEX_STD ostream* new_out = 0 ) = 0;
|
|---|
| 88 |
|
|---|
| 89 | int lineno() const { return yylineno; }
|
|---|
| 90 |
|
|---|
| 91 | int debug() const { return yy_flex_debug; }
|
|---|
| 92 | void set_debug( int flag ) { yy_flex_debug = flag; }
|
|---|
| 93 |
|
|---|
| 94 | protected:
|
|---|
| 95 | char* yytext;
|
|---|
|
|---|