File indexing completed on 2024-07-07 14:16:58

0001 // -*-C++-*-
0002 // FlexLexer.h -- define interfaces for lexical analyzer classes generated
0003 // by flex
0004 
0005 // SPDX-FileCopyrightText: 1993 The Regents of the University of California. All rights reserved.
0006 // SPDX-FileContributor: This code is derived from software contributed to Berkeley by Kent Williams and Tom Epperly.
0007 //
0008 // SPDX-License-Identifier: BSD-2-Clause
0009 
0010 // This file defines FlexLexer, an abstract class which specifies the
0011 // external interface provided to flex C++ lexer objects, and yyFlexLexer,
0012 // which defines a particular lexer class.
0013 //
0014 // If you want to create multiple lexer classes, you use the -P flag
0015 // to rename each yyFlexLexer to some other xxFlexLexer.  You then
0016 // include <FlexLexer.h> in your other sources once per lexer class:
0017 //
0018 //  #undef yyFlexLexer
0019 //  #define yyFlexLexer xxFlexLexer
0020 //  #include <FlexLexer.h>
0021 //
0022 //  #undef yyFlexLexer
0023 //  #define yyFlexLexer zzFlexLexer
0024 //  #include <FlexLexer.h>
0025 //  ...
0026 
0027 #ifndef __FLEX_LEXER_H
0028 // Never included before - need to define base class.
0029 #define __FLEX_LEXER_H
0030 
0031 #include <iostream>
0032 #ifndef FLEX_STD
0033 #define FLEX_STD std::
0034 #endif
0035 
0036 extern "C++" {
0037 
0038 struct yy_buffer_state;
0039 typedef int yy_state_type;
0040 
0041 class FlexLexer
0042 {
0043 public:
0044     virtual ~FlexLexer()
0045     {
0046     }
0047 
0048     const char *YYText() const
0049     {
0050         return yytext;
0051     }
0052     int YYLeng() const
0053     {
0054         return yyleng;
0055     }
0056 
0057     virtual void yy_switch_to_buffer(struct yy_buffer_state *new_buffer) = 0;
0058     virtual struct yy_buffer_state *yy_create_buffer(FLEX_STD istream *s, int size) = 0;
0059     virtual void yy_delete_buffer(struct yy_buffer_state *b) = 0;
0060     virtual void yyrestart(FLEX_STD istream *s) = 0;
0061 
0062     virtual int yylex() = 0;
0063 
0064     // Call yylex with new input/output sources.
0065     int yylex(FLEX_STD istream *new_in, FLEX_STD ostream *new_out = nullptr)
0066     {
0067         switch_streams(new_in, new_out);
0068         return yylex();
0069     }
0070 
0071     // Switch to new input/output streams.  A nil stream pointer
0072     // indicates "keep the current one".
0073     virtual void switch_streams(FLEX_STD istream *new_in = nullptr, FLEX_STD ostream *new_out = nullptr) = 0;
0074 
0075     int lineno() const
0076     {
0077         return yylineno;
0078     }
0079 
0080     int debug() const
0081     {
0082         return yy_flex_debug;
0083     }
0084     void set_debug(int flag)
0085     {
0086         yy_flex_debug = flag;
0087     }
0088 
0089 protected:
0090     char *yytext;
0091     int yyleng;
0092     int yylineno; // only maintained if you use %option yylineno
0093     int yy_flex_debug; // only has effect with -d or "%option debug"
0094 };
0095 }
0096 #endif // FLEXLEXER_H
0097 
0098 #if defined(yyFlexLexer) || !defined(yyFlexLexerOnce)
0099 // Either this is the first time through (yyFlexLexerOnce not defined),
0100 // or this is a repeated include to define a different flavor of
0101 // yyFlexLexer, as discussed in the flex manual.
0102 #define yyFlexLexerOnce
0103 
0104 extern "C++" {
0105 
0106 class yyFlexLexer : public FlexLexer
0107 {
0108 public:
0109     // arg_yyin and arg_yyout default to the cin and cout, but we
0110     // only make that assignment when initializing in yylex().
0111     yyFlexLexer(FLEX_STD istream *arg_yyin = nullptr, FLEX_STD ostream *arg_yyout = nullptr);
0112 
0113     ~yyFlexLexer() override;
0114 
0115     void yy_switch_to_buffer(struct yy_buffer_state *new_buffer) override;
0116     struct yy_buffer_state *yy_create_buffer(FLEX_STD istream *s, int size) override;
0117     void yy_delete_buffer(struct yy_buffer_state *b) override;
0118     void yyrestart(FLEX_STD istream *s) override;
0119 
0120     void yypush_buffer_state(struct yy_buffer_state *new_buffer);
0121     void yypop_buffer_state();
0122 
0123     virtual int yylex() override;
0124     virtual void switch_streams(FLEX_STD istream *new_in, FLEX_STD ostream *new_out = nullptr) override;
0125     virtual int yywrap();
0126 
0127 protected:
0128     virtual int LexerInput(char *buf, int max_size);
0129     virtual void LexerOutput(const char *buf, int size);
0130     virtual void LexerError(const char *msg);
0131 
0132     void yyunput(int c, char *buf_ptr);
0133     int yyinput();
0134 
0135     void yy_load_buffer_state();
0136     void yy_init_buffer(struct yy_buffer_state *b, FLEX_STD istream *s);
0137     void yy_flush_buffer(struct yy_buffer_state *b);
0138 
0139     int yy_start_stack_ptr;
0140     int yy_start_stack_depth;
0141     int *yy_start_stack;
0142 
0143     void yy_push_state(int new_state);
0144     void yy_pop_state();
0145     int yy_top_state();
0146 
0147     yy_state_type yy_get_previous_state();
0148     yy_state_type yy_try_NUL_trans(yy_state_type current_state);
0149     int yy_get_next_buffer();
0150 
0151     FLEX_STD istream *yyin; // input source for default LexerInput
0152     FLEX_STD ostream *yyout; // output sink for default LexerOutput
0153 
0154     // yy_hold_char holds the character lost when yytext is formed.
0155     char yy_hold_char;
0156 
0157     // Number of characters read into yy_ch_buf.
0158     int yy_n_chars;
0159 
0160     // Points to current character in buffer.
0161     char *yy_c_buf_p;
0162 
0163     int yy_init; // whether we need to initialize
0164     int yy_start; // start state number
0165 
0166     // Flag which is used to allow yywrap()'s to do buffer switches
0167     // instead of setting up a fresh yyin.  A bit of a hack ...
0168     int yy_did_buffer_switch_on_eof;
0169 
0170     size_t yy_buffer_stack_top; /**< index of top of stack. */
0171     size_t yy_buffer_stack_max; /**< capacity of stack. */
0172     struct yy_buffer_state **yy_buffer_stack; /**< Stack as an array. */
0173     void yyensure_buffer_stack(void);
0174 
0175     // The following are not always needed, but may be depending
0176     // on use of certain flex features (like REJECT or yymore()).
0177 
0178     yy_state_type yy_last_accepting_state;
0179     char *yy_last_accepting_cpos;
0180 
0181     yy_state_type *yy_state_buf;
0182     yy_state_type *yy_state_ptr;
0183 
0184     char *yy_full_match;
0185     int *yy_full_state;
0186     int yy_full_lp;
0187 
0188     int yy_lp;
0189     int yy_looking_for_trail_begin;
0190 
0191     int yy_more_flag;
0192     int yy_more_len;
0193     int yy_more_offset;
0194     int yy_prev_more_offset;
0195 };
0196 }
0197 
0198 #endif // yyFlexLexer || ! yyFlexLexerOnce