Mercurial > hg > octave-avbm
annotate src/lex.h @ 7855:f317f14516cb
Add zoom stack facility in axes object.
author | Michael Goffioul <michael.goffioul@gmail.com> |
---|---|
date | Tue, 04 Mar 2008 15:34:38 +0100 |
parents | 74f5e0c7de9e |
children | ff9e7873f8ea |
rev | line source |
---|---|
1 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002, |
4 2003, 2004, 2005, 2006, 2007 John W. Eaton | |
1 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
1 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
1 | 21 |
22 */ | |
23 | |
383 | 24 #if !defined (octave_lex_h) |
25 #define octave_lex_h 1 | |
1 | 26 |
5775 | 27 // FIXME -- these input buffer things should be members of a |
1826 | 28 // parser input stream class. |
29 | |
1 | 30 typedef struct yy_buffer_state *YY_BUFFER_STATE; |
31 | |
32 // Associate a buffer with a new file to read. | |
33 extern YY_BUFFER_STATE create_buffer (FILE *f); | |
34 | |
35 // Report the current buffer. | |
36 extern YY_BUFFER_STATE current_buffer (void); | |
37 | |
38 // Connect to new buffer buffer. | |
39 extern void switch_to_buffer (YY_BUFFER_STATE buf); | |
40 | |
41 // Delete a buffer. | |
42 extern void delete_buffer (YY_BUFFER_STATE buf); | |
43 | |
44 // Restore a buffer (for unwind-prot). | |
45 extern void restore_input_buffer (void *buf); | |
46 | |
47 // Delete a buffer (for unwind-prot). | |
48 extern void delete_input_buffer (void *buf); | |
49 | |
4867 | 50 // Is the given string a keyword? |
51 extern bool is_keyword (const std::string& s); | |
52 | |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7634
diff
changeset
|
53 extern void prep_lexer_for_script (void); |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7634
diff
changeset
|
54 |
1826 | 55 // For communication between the lexer and parser. |
56 | |
3585 | 57 class |
58 lexical_feedback | |
1826 | 59 { |
60 public: | |
61 | |
62 lexical_feedback (void) { init (); } | |
63 | |
64 ~lexical_feedback (void) { } | |
65 | |
66 void init (void); | |
67 | |
3351 | 68 // Square bracket level count. |
69 int bracketflag; | |
1826 | 70 |
4613 | 71 // Curly brace level count. |
72 int braceflag; | |
73 | |
2877 | 74 // TRUE means we're in the middle of defining a loop. |
1826 | 75 int looping; |
76 | |
2877 | 77 // TRUE means that we should convert spaces to a comma inside a |
2857 | 78 // matrix definition. |
79 bool convert_spaces_to_comma; | |
80 | |
2877 | 81 // TRUE means we're in the middle of defining a function. |
2857 | 82 bool defining_func; |
83 | |
4930 | 84 // Nonzero means we are parsing a function handle. |
85 int looking_at_function_handle; | |
86 | |
2877 | 87 // TRUE means we're parsing the return list for a function. |
2857 | 88 bool looking_at_return_list; |
89 | |
2877 | 90 // TRUE means we're parsing the parameter list for a function. |
2857 | 91 bool looking_at_parameter_list; |
92 | |
7634
ae90e05ad299
fix parameter list initializer bug
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
93 // TRUE means we are looking at the initializer expression for a |
ae90e05ad299
fix parameter list initializer bug
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
94 // parameter list element. |
ae90e05ad299
fix parameter list initializer bug
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
95 bool looking_at_initializer_expression; |
ae90e05ad299
fix parameter list initializer bug
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
96 |
3189 | 97 // TRUE means we're parsing a matrix or the left hand side of |
98 // multi-value assignment statement. | |
99 bool looking_at_matrix_or_assign_lhs; | |
100 | |
4237 | 101 // Nonzero means we're parsing an indexing operation for an object. |
102 int looking_at_object_index; | |
4234 | 103 |
2857 | 104 // GAG. Stupid kludge so that [[1,2][3,4]] will work. |
105 bool do_comma_insert; | |
106 | |
5102 | 107 // TRUE means we're doing a raw input command. |
108 bool doing_rawcommand; | |
109 | |
2877 | 110 // TRUE means we're looking at an indirect reference to a |
2857 | 111 // structure element. |
112 bool looking_at_indirect_ref; | |
113 | |
2877 | 114 // TRUE means that we've already seen the name of this function. |
115 // Should only matter if defining_func is also TRUE. | |
116 bool parsed_function_name; | |
117 | |
4240 | 118 // Are we parsing a nested function? |
119 // 1 ==> Yes. | |
120 // 0 ==> No. | |
121 // -1 ==> Yes, but it is the last one because we have seen EOF. | |
122 int parsing_nested_function; | |
4238 | 123 |
7336 | 124 // TRUE means we are parsing a class method. |
125 bool parsing_class_method; | |
126 | |
1826 | 127 // Return transpose or start a string? |
2857 | 128 bool quote_is_transpose; |
1826 | 129 |
130 private: | |
131 | |
132 lexical_feedback (const lexical_feedback&); | |
133 | |
134 lexical_feedback& operator = (const lexical_feedback&); | |
135 }; | |
136 | |
7720
4e2eafef689c
unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
137 class |
4e2eafef689c
unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
138 stream_reader |
4e2eafef689c
unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
139 { |
4e2eafef689c
unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
140 public: |
4e2eafef689c
unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
141 virtual int getc (void) = 0; |
4e2eafef689c
unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
142 virtual int ungetc (int c) = 0; |
4e2eafef689c
unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
143 |
4e2eafef689c
unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
144 protected: |
4e2eafef689c
unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
145 stream_reader (void) { } |
4e2eafef689c
unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
146 ~stream_reader (void) { } |
4e2eafef689c
unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
147 |
4e2eafef689c
unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
148 private: |
4e2eafef689c
unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
149 |
4e2eafef689c
unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
150 // No copying! |
4e2eafef689c
unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
151 stream_reader (const stream_reader&); |
4e2eafef689c
unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
152 stream_reader& operator = (const stream_reader&); |
4e2eafef689c
unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
153 }; |
4e2eafef689c
unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
154 |
7723
74f5e0c7de9e
first pass at handling block comments
John W. Eaton <jwe@octave.org>
parents:
7720
diff
changeset
|
155 extern std::string |
74f5e0c7de9e
first pass at handling block comments
John W. Eaton <jwe@octave.org>
parents:
7720
diff
changeset
|
156 grab_comment_block (stream_reader& reader, bool at_bol, bool& eof); |
7720
4e2eafef689c
unify comment and help text processing in lex.l and parse.y
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
157 |
3883 | 158 // TRUE means that we have encountered EOF on the input stream. |
159 extern bool parser_end_of_input; | |
160 | |
1826 | 161 // Flags that need to be shared between the lexer and parser. |
162 extern lexical_feedback lexer_flags; | |
440 | 163 |
1 | 164 #endif |
165 | |
166 /* | |
167 ;;; Local Variables: *** | |
168 ;;; mode: C++ *** | |
169 ;;; End: *** | |
170 */ |