1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: FlexLexer.h,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef __FLEX_LEXER_H
31 // Never included before - need to define base class.
32 #define __FLEX_LEXER_H
33 //#include <iostream.h>
36 #include <rtftok/RTFInputSource.hxx>
40 struct yy_buffer_state
;
41 typedef int yy_state_type
;
44 #include <rtftok/RTFScanner.hxx>
47 #if defined(yyFlexLexer) || ! defined(yyFlexLexerOnce)
48 // Either this is the first time through (yyFlexLexerOnce not defined),
49 // or this is a repeated include to define a different flavor of
50 // yyFlexLexer, as discussed in the flex man page.
51 #define yyFlexLexerOnce
53 class yyFlexLexer
: public writerfilter::rtftok::RTFScanner
{
55 class RtfTokenizer
* tokenizerInstance
;
57 void split_ctrl(char *yytext
, char* token
, char *value
);
58 void raise_ctrl(char* yytext
);
59 void raise_dest(char* yytext
);
60 void raise_destOrCtrl(char* yytext
);
67 // arg_yyin and arg_yyout default to the cin and cout, but we
68 // only make that assignment when initializing in yylex().
69 yyFlexLexer( class writerfilter::rtftok::RTFInputSource
* arg_yyin
, class writerfilter::rtftok::RTFScannerHandler
&eventHandler
);
71 virtual ~yyFlexLexer();
73 void yy_switch_to_buffer( struct yy_buffer_state
* new_buffer
);
74 struct yy_buffer_state
* yy_create_buffer( class writerfilter::rtftok::RTFInputSource
* s
, int size
);
75 void yy_delete_buffer( struct yy_buffer_state
* b
);
76 void yyrestart( class writerfilter::rtftok::RTFInputSource
* s
);
79 virtual void switch_streams( class writerfilter::rtftok::RTFInputSource
* new_in
, ostream
* new_out
);
83 // int LexerInput( char* buf, int max_size );
84 virtual void LexerOutput( const char* buf
, int size
);
85 virtual void LexerError( const char* msg
);
87 void yyunput( int c
, char* buf_ptr
);
90 void yy_load_buffer_state();
91 void yy_init_buffer( struct yy_buffer_state
* b
, class writerfilter::rtftok::RTFInputSource
* s
);
92 void yy_flush_buffer( struct yy_buffer_state
* b
);
94 int yy_start_stack_ptr
;
95 int yy_start_stack_depth
;
98 void yy_push_state( int new_state
);
102 yy_state_type
yy_get_previous_state();
103 yy_state_type
yy_try_NUL_trans( yy_state_type current_state
);
104 int yy_get_next_buffer();
106 class writerfilter::rtftok::RTFInputSource
* yyin
; // input source for default LexerInput
107 ostream
* yyout
; // output sink for default LexerOutput
109 struct yy_buffer_state
* yy_current_buffer
;
111 // yy_hold_char holds the character lost when yytext is formed.
114 // Number of characters read into yy_ch_buf.
117 // Points to current character in buffer.
120 int yy_init
; // whether we need to initialize
121 int yy_start
; // start state number
123 // Flag which is used to allow yywrap()'s to do buffer switches
124 // instead of setting up a fresh yyin. A bit of a hack ...
125 int yy_did_buffer_switch_on_eof
;
127 // The following are not always needed, but may be depending
128 // on use of certain flex features (like REJECT or yymore()).
130 yy_state_type yy_last_accepting_state
;
131 char* yy_last_accepting_cpos
;
133 yy_state_type
* yy_state_buf
;
134 yy_state_type
* yy_state_ptr
;
141 int yy_looking_for_trail_begin
;
146 int yy_prev_more_offset
;