Mercurial > octave-nkf
annotate libinterp/parse-tree/lex.h @ 16211:3449bf257514 classdef
maint: fix botched merge of default to classdef
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 07 Mar 2013 10:23:02 -0500 |
parents | a8f9eb92fa6e |
children | d2b268936783 |
rev | line source |
---|---|
1 | 1 /* |
2 | |
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
13973
diff
changeset
|
3 Copyright (C) 1993-2012 John W. Eaton |
1 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
1 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
1 | 20 |
21 */ | |
22 | |
383 | 23 #if !defined (octave_lex_h) |
24 #define octave_lex_h 1 | |
1 | 25 |
8745
6dc61981d18b
better handling of object indexing in lexer
John W. Eaton <jwe@octave.org>
parents:
8701
diff
changeset
|
26 #include <list> |
16101
8d19626b38ae
provide copy contructor and operator = for lexical_feedback class.
John W. Eaton <jwe@octave.org>
parents:
16100
diff
changeset
|
27 #include <set> |
11464
21b5284fa78d
avoid error when parsing nested functions
John W. Eaton <jwe@octave.org>
parents:
11367
diff
changeset
|
28 #include <stack> |
8745
6dc61981d18b
better handling of object indexing in lexer
John W. Eaton <jwe@octave.org>
parents:
8701
diff
changeset
|
29 |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16194
diff
changeset
|
30 #include "input.h" |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16194
diff
changeset
|
31 |
13973
2c664266e9d0
clean up parser memory on exit
John W. Eaton <jwe@octave.org>
parents:
13237
diff
changeset
|
32 extern OCTINTERP_API void cleanup_parser (void); |
2c664266e9d0
clean up parser memory on exit
John W. Eaton <jwe@octave.org>
parents:
13237
diff
changeset
|
33 |
4867 | 34 // Is the given string a keyword? |
35 extern bool is_keyword (const std::string& s); | |
36 | |
16113
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
37 class |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
38 stream_reader |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
39 { |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
40 public: |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
41 virtual int getc (void) = 0; |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
42 virtual int ungetc (int c) = 0; |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
43 |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
44 protected: |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
45 stream_reader (void) { } |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
46 ~stream_reader (void) { } |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
47 |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
48 private: |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
49 |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
50 // No copying! |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
51 stream_reader (const stream_reader&); |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
52 stream_reader& operator = (const stream_reader&); |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
53 }; |
16111
3ec4f6488569
move token stack to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16110
diff
changeset
|
54 |
16158
7eb614760ddb
rename lexical_feedback to octave_lexer
John W. Eaton <jwe@octave.org>
parents:
16149
diff
changeset
|
55 // Forward decl for octave_lexer::token_stack. |
16111
3ec4f6488569
move token stack to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16110
diff
changeset
|
56 class token; |
3ec4f6488569
move token stack to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16110
diff
changeset
|
57 |
1826 | 58 // For communication between the lexer and parser. |
59 | |
3585 | 60 class |
16193
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
61 lexical_feedback |
1826 | 62 { |
63 public: | |
64 | |
16106
031117f4db7c
use enum for values returned by eat_continuation and eat_whitespace
John W. Eaton <jwe@octave.org>
parents:
16105
diff
changeset
|
65 // Did eat_whitespace or eat_continuation eat a space or tab, or a |
031117f4db7c
use enum for values returned by eat_continuation and eat_whitespace
John W. Eaton <jwe@octave.org>
parents:
16105
diff
changeset
|
66 // newline, or both? |
031117f4db7c
use enum for values returned by eat_continuation and eat_whitespace
John W. Eaton <jwe@octave.org>
parents:
16105
diff
changeset
|
67 // |
031117f4db7c
use enum for values returned by eat_continuation and eat_whitespace
John W. Eaton <jwe@octave.org>
parents:
16105
diff
changeset
|
68 // Functions that return this type will return a logical OR of the |
031117f4db7c
use enum for values returned by eat_continuation and eat_whitespace
John W. Eaton <jwe@octave.org>
parents:
16105
diff
changeset
|
69 // following values: |
031117f4db7c
use enum for values returned by eat_continuation and eat_whitespace
John W. Eaton <jwe@octave.org>
parents:
16105
diff
changeset
|
70 // |
031117f4db7c
use enum for values returned by eat_continuation and eat_whitespace
John W. Eaton <jwe@octave.org>
parents:
16105
diff
changeset
|
71 // NO_WHITESPACE no spaces to eat |
031117f4db7c
use enum for values returned by eat_continuation and eat_whitespace
John W. Eaton <jwe@octave.org>
parents:
16105
diff
changeset
|
72 // SPACE_OR_TAB space or tab in input |
031117f4db7c
use enum for values returned by eat_continuation and eat_whitespace
John W. Eaton <jwe@octave.org>
parents:
16105
diff
changeset
|
73 // NEWLINE bare new line in input |
031117f4db7c
use enum for values returned by eat_continuation and eat_whitespace
John W. Eaton <jwe@octave.org>
parents:
16105
diff
changeset
|
74 |
031117f4db7c
use enum for values returned by eat_continuation and eat_whitespace
John W. Eaton <jwe@octave.org>
parents:
16105
diff
changeset
|
75 enum whitespace_type |
031117f4db7c
use enum for values returned by eat_continuation and eat_whitespace
John W. Eaton <jwe@octave.org>
parents:
16105
diff
changeset
|
76 { |
031117f4db7c
use enum for values returned by eat_continuation and eat_whitespace
John W. Eaton <jwe@octave.org>
parents:
16105
diff
changeset
|
77 NO_WHITESPACE = 1, |
031117f4db7c
use enum for values returned by eat_continuation and eat_whitespace
John W. Eaton <jwe@octave.org>
parents:
16105
diff
changeset
|
78 SPACE_OR_TAB = 2, |
031117f4db7c
use enum for values returned by eat_continuation and eat_whitespace
John W. Eaton <jwe@octave.org>
parents:
16105
diff
changeset
|
79 NEWLINE = 4 |
031117f4db7c
use enum for values returned by eat_continuation and eat_whitespace
John W. Eaton <jwe@octave.org>
parents:
16105
diff
changeset
|
80 }; |
031117f4db7c
use enum for values returned by eat_continuation and eat_whitespace
John W. Eaton <jwe@octave.org>
parents:
16105
diff
changeset
|
81 |
16104
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
82 // Track nesting of square brackets, curly braces, and parentheses. |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
83 |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
84 class bbp_nesting_level |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
85 { |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
86 private: |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
87 |
16107
3b791008b88e
give name to anonymous enum
John W. Eaton <jwe@octave.org>
parents:
16106
diff
changeset
|
88 enum bracket_type |
16104
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
89 { |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
90 BRACKET = 1, |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
91 BRACE = 2, |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
92 PAREN = 3 |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
93 }; |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
94 |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
95 public: |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
96 |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
97 bbp_nesting_level (void) : context () { } |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
98 |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
99 bbp_nesting_level (const bbp_nesting_level& nl) : context (nl.context) { } |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
100 |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
101 bbp_nesting_level& operator = (const bbp_nesting_level& nl) |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
102 { |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
103 if (&nl != this) |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
104 context = nl.context; |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
105 |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
106 return *this; |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
107 } |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
108 |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
109 ~bbp_nesting_level (void) { } |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
110 |
16194
b7ca669af528
reset lexical_feedback state before starting a new parse
John W. Eaton <jwe@octave.org>
parents:
16193
diff
changeset
|
111 void reset (void) |
b7ca669af528
reset lexical_feedback state before starting a new parse
John W. Eaton <jwe@octave.org>
parents:
16193
diff
changeset
|
112 { |
b7ca669af528
reset lexical_feedback state before starting a new parse
John W. Eaton <jwe@octave.org>
parents:
16193
diff
changeset
|
113 while (! context.empty ()) |
b7ca669af528
reset lexical_feedback state before starting a new parse
John W. Eaton <jwe@octave.org>
parents:
16193
diff
changeset
|
114 context.pop (); |
b7ca669af528
reset lexical_feedback state before starting a new parse
John W. Eaton <jwe@octave.org>
parents:
16193
diff
changeset
|
115 } |
b7ca669af528
reset lexical_feedback state before starting a new parse
John W. Eaton <jwe@octave.org>
parents:
16193
diff
changeset
|
116 |
16104
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
117 void bracket (void) { context.push (BRACKET); } |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
118 |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
119 bool is_bracket (void) |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
120 { |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
121 return ! context.empty () && context.top () == BRACKET; |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
122 } |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
123 |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
124 void brace (void) { context.push (BRACE); } |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
125 |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
126 bool is_brace (void) |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
127 { |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
128 return ! context.empty () && context.top () == BRACE; |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
129 } |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
130 |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
131 void paren (void) { context.push (PAREN); } |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
132 |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
133 bool is_paren (void) |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
134 { |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
135 return ! context.empty () && context.top () == PAREN; |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
136 } |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
137 |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
138 bool is_bracket_or_brace (void) |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
139 { |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
140 return (! context.empty () |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
141 && (context.top () == BRACKET || context.top () == BRACE)); |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
142 } |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
143 |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
144 bool none (void) { return context.empty (); } |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
145 |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
146 void remove (void) |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
147 { |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
148 if (! context.empty ()) |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
149 context.pop (); |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
150 } |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
151 |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
152 void clear (void) |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
153 { |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
154 while (! context.empty ()) |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
155 context.pop (); |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
156 } |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
157 |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
158 private: |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
159 |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
160 std::stack<int> context; |
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
161 }; |
16193
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
162 |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
163 lexical_feedback (void) |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
164 : end_of_input (false), convert_spaces_to_comma (true), |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
165 do_comma_insert (false), at_beginning_of_statement (true), |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
166 looking_at_anon_fcn_args (false), looking_at_return_list (false), |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
167 looking_at_parameter_list (false), looking_at_decl_list (false), |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
168 looking_at_initializer_expression (false), |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
169 looking_at_matrix_or_assign_lhs (false), |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
170 looking_for_object_index (false), |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
171 looking_at_indirect_ref (false), parsing_class_method (false), |
16211
3449bf257514
maint: fix botched merge of default to classdef
John W. Eaton <jwe@octave.org>
parents:
16205
diff
changeset
|
172 parsing_classdef (false), maybe_classdef_get_set_method (false), |
3449bf257514
maint: fix botched merge of default to classdef
John W. Eaton <jwe@octave.org>
parents:
16205
diff
changeset
|
173 parsing_classdef_get_method (false), |
3449bf257514
maint: fix botched merge of default to classdef
John W. Eaton <jwe@octave.org>
parents:
16205
diff
changeset
|
174 parsing_classdef_set_method (false), |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
175 quote_is_transpose (false), force_script (false), |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
176 reading_fcn_file (false), reading_script_file (false), |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
177 reading_classdef_file (false), |
16193
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
178 input_line_number (1), current_input_column (1), |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
179 bracketflag (0), braceflag (0), |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
180 looping (0), defining_func (0), looking_at_function_handle (0), |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
181 block_comment_nesting_level (0), token_count (0), |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
182 help_text (), fcn_file_name (), fcn_file_full_name (), |
16193
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
183 looking_at_object_index (), parsed_function_name (), |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
184 pending_local_variables (), nesting_level (), token_stack () |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
185 { |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
186 init (); |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
187 } |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
188 |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
189 ~lexical_feedback (void); |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
190 |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
191 void init (void); |
16194
b7ca669af528
reset lexical_feedback state before starting a new parse
John W. Eaton <jwe@octave.org>
parents:
16193
diff
changeset
|
192 |
b7ca669af528
reset lexical_feedback state before starting a new parse
John W. Eaton <jwe@octave.org>
parents:
16193
diff
changeset
|
193 void reset (void); |
b7ca669af528
reset lexical_feedback state before starting a new parse
John W. Eaton <jwe@octave.org>
parents:
16193
diff
changeset
|
194 |
16193
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
195 // true means that we have encountered eof on the input stream. |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
196 bool end_of_input; |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
197 |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
198 // true means that we should convert spaces to a comma inside a |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
199 // matrix definition. |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
200 bool convert_spaces_to_comma; |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
201 |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
202 // gag. stupid kludge so that [[1,2][3,4]] will work. |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
203 bool do_comma_insert; |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
204 |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
205 // true means we are at the beginning of a statement, where a |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
206 // command name is possible. |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
207 bool at_beginning_of_statement; |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
208 |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
209 // true means we are parsing an anonymous function argument list. |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
210 bool looking_at_anon_fcn_args; |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
211 |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
212 // true means we're parsing the return list for a function. |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
213 bool looking_at_return_list; |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
214 |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
215 // true means we're parsing the parameter list for a function. |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
216 bool looking_at_parameter_list; |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
217 |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
218 // true means we're parsing a declaration list (global or |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
219 // persistent). |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
220 bool looking_at_decl_list; |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
221 |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
222 // true means we are looking at the initializer expression for a |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
223 // parameter list element. |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
224 bool looking_at_initializer_expression; |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
225 |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
226 // true means we're parsing a matrix or the left hand side of |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
227 // multi-value assignment statement. |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
228 bool looking_at_matrix_or_assign_lhs; |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
229 |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
230 // object index not possible until we've seen something. |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
231 bool looking_for_object_index; |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
232 |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
233 // true means we're looking at an indirect reference to a |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
234 // structure element. |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
235 bool looking_at_indirect_ref; |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
236 |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
237 // true means we are parsing a class method in function or classdef file. |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
238 bool parsing_class_method; |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
239 |
16211
3449bf257514
maint: fix botched merge of default to classdef
John W. Eaton <jwe@octave.org>
parents:
16205
diff
changeset
|
240 // true means we are parsing a classdef file |
3449bf257514
maint: fix botched merge of default to classdef
John W. Eaton <jwe@octave.org>
parents:
16205
diff
changeset
|
241 bool parsing_classdef; |
3449bf257514
maint: fix botched merge of default to classdef
John W. Eaton <jwe@octave.org>
parents:
16205
diff
changeset
|
242 |
16193
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
243 // true means we are parsing a class method declaration line in a |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
244 // classdef file and can accept a property get or set method name. |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
245 // for example, "get.propertyname" is recognized as a function name. |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
246 bool maybe_classdef_get_set_method; |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
247 |
16211
3449bf257514
maint: fix botched merge of default to classdef
John W. Eaton <jwe@octave.org>
parents:
16205
diff
changeset
|
248 // TRUE means we are parsing a classdef get.method. |
3449bf257514
maint: fix botched merge of default to classdef
John W. Eaton <jwe@octave.org>
parents:
16205
diff
changeset
|
249 bool parsing_classdef_get_method; |
3449bf257514
maint: fix botched merge of default to classdef
John W. Eaton <jwe@octave.org>
parents:
16205
diff
changeset
|
250 |
3449bf257514
maint: fix botched merge of default to classdef
John W. Eaton <jwe@octave.org>
parents:
16205
diff
changeset
|
251 // TRUE means we are parsing a classdef set.method. |
3449bf257514
maint: fix botched merge of default to classdef
John W. Eaton <jwe@octave.org>
parents:
16205
diff
changeset
|
252 bool parsing_classdef_set_method; |
16193
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
253 |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
254 // return transpose or start a string? |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
255 bool quote_is_transpose; |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
256 |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
257 // TRUE means treat the current file as a script even if the first |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
258 // token is "function" or "classdef". |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
259 bool force_script; |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
260 |
16199
810a71122c25
move more global variables to octave_lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
261 // TRUE means we're parsing a function file. |
810a71122c25
move more global variables to octave_lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
262 bool reading_fcn_file; |
810a71122c25
move more global variables to octave_lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
263 |
810a71122c25
move more global variables to octave_lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
264 // TRUE means we're parsing a script file. |
810a71122c25
move more global variables to octave_lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
265 bool reading_script_file; |
810a71122c25
move more global variables to octave_lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
266 |
810a71122c25
move more global variables to octave_lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
267 // TRUE means we're parsing a classdef file. |
810a71122c25
move more global variables to octave_lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
268 bool reading_classdef_file; |
810a71122c25
move more global variables to octave_lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16195
diff
changeset
|
269 |
16193
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
270 // the current input line number. |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
271 int input_line_number; |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
272 |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
273 // the column of the current token. |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
274 int current_input_column; |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
275 |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
276 // square bracket level count. |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
277 int bracketflag; |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
278 |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
279 // curly brace level count. |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
280 int braceflag; |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
281 |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
282 // true means we're in the middle of defining a loop. |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
283 int looping; |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
284 |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
285 // nonzero means we're in the middle of defining a function. |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
286 int defining_func; |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
287 |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
288 // nonzero means we are parsing a function handle. |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
289 int looking_at_function_handle; |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
290 |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
291 // nestng level for blcok comments. |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
292 int block_comment_nesting_level; |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
293 |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
294 // Count of tokens recognized by this lexer since initialized or |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
295 // since the last reset. |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
296 size_t token_count; |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
297 |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
298 // The current help text. |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
299 std::string help_text; |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
300 |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
301 // Simple name of function file we are reading. |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
302 std::string fcn_file_name; |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
303 |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
304 // Full name of file we are reading. |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
305 std::string fcn_file_full_name; |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
306 |
16193
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
307 // if the front of the list is true, the closest paren, brace, or |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
308 // bracket nesting is an index for an object. |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
309 std::list<bool> looking_at_object_index; |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
310 |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
311 // if the top of the stack is true, then we've already seen the name |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
312 // of the current function. should only matter if |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
313 // current_function_level > 0 |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
314 std::stack<bool> parsed_function_name; |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
315 |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
316 // set of identifiers that might be local variable names. |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
317 std::set<std::string> pending_local_variables; |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
318 |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
319 // is the closest nesting level a square bracket, squiggly brace or |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
320 // a paren? |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
321 bbp_nesting_level nesting_level; |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
322 |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
323 // Stack to hold tokens so that we can delete them when the parser is |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
324 // reset and avoid growing forever just because we are stashing some |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
325 // information. |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
326 std::stack <token*> token_stack; |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
327 |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
328 private: |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
329 |
16194
b7ca669af528
reset lexical_feedback state before starting a new parse
John W. Eaton <jwe@octave.org>
parents:
16193
diff
changeset
|
330 void reset_token_stack (void); |
b7ca669af528
reset lexical_feedback state before starting a new parse
John W. Eaton <jwe@octave.org>
parents:
16193
diff
changeset
|
331 |
16193
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
332 // No copying! |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
333 |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
334 lexical_feedback (const lexical_feedback&); |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
335 |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
336 lexical_feedback& operator = (const lexical_feedback&); |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
337 }; |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
338 |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
339 // octave_lexer inherits from lexical_feedback because we will |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
340 // eventually have several different constructors and it is easier to |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
341 // intialize if everything is grouped in a parent class rather than |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
342 // listing all the members in the octave_lexer class. |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
343 |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
344 class |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
345 octave_lexer : public lexical_feedback |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
346 { |
d7392bf42fd1
use inheritance to simplify initialization in octave_lexer constructor
John W. Eaton <jwe@octave.org>
parents:
16185
diff
changeset
|
347 public: |
16104
c8974e28da59
move nesting_level to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
348 |
16183
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
349 // Handle buffering of input for lexer. |
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
350 |
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
351 class input_buffer |
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
352 { |
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
353 public: |
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
354 |
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
355 input_buffer (void) |
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
356 : buffer (), pos (0), chars_left (0), eof (false) |
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
357 { } |
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
358 |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16194
diff
changeset
|
359 void fill (const std::string& input, bool eof_arg); |
16183
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
360 |
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
361 // Copy at most max_size characters to buf. |
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
362 int copy_chunk (char *buf, size_t max_size); |
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
363 |
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
364 bool empty (void) const { return chars_left == 0; } |
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
365 |
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
366 bool at_eof (void) const { return eof; } |
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
367 |
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
368 private: |
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
369 |
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
370 std::string buffer; |
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
371 const char *pos; |
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
372 size_t chars_left; |
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
373 bool eof; |
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
374 }; |
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
375 |
16158
7eb614760ddb
rename lexical_feedback to octave_lexer
John W. Eaton <jwe@octave.org>
parents:
16149
diff
changeset
|
376 octave_lexer (void) |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16194
diff
changeset
|
377 : lexical_feedback (), scanner (0), input_buf (), input_reader () |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16194
diff
changeset
|
378 { |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16194
diff
changeset
|
379 init (); |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16194
diff
changeset
|
380 } |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16194
diff
changeset
|
381 |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16194
diff
changeset
|
382 octave_lexer (FILE *file) |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16194
diff
changeset
|
383 : lexical_feedback (), scanner (0), input_buf (), |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16194
diff
changeset
|
384 input_reader (file) |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16194
diff
changeset
|
385 { |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16194
diff
changeset
|
386 init (); |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16194
diff
changeset
|
387 } |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16194
diff
changeset
|
388 |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16194
diff
changeset
|
389 octave_lexer (const std::string& eval_string) |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16194
diff
changeset
|
390 : lexical_feedback (), scanner (0), input_buf (), |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16194
diff
changeset
|
391 input_reader (eval_string) |
16101
8d19626b38ae
provide copy contructor and operator = for lexical_feedback class.
John W. Eaton <jwe@octave.org>
parents:
16100
diff
changeset
|
392 { |
8d19626b38ae
provide copy contructor and operator = for lexical_feedback class.
John W. Eaton <jwe@octave.org>
parents:
16100
diff
changeset
|
393 init (); |
8d19626b38ae
provide copy contructor and operator = for lexical_feedback class.
John W. Eaton <jwe@octave.org>
parents:
16100
diff
changeset
|
394 } |
8d19626b38ae
provide copy contructor and operator = for lexical_feedback class.
John W. Eaton <jwe@octave.org>
parents:
16100
diff
changeset
|
395 |
16158
7eb614760ddb
rename lexical_feedback to octave_lexer
John W. Eaton <jwe@octave.org>
parents:
16149
diff
changeset
|
396 ~octave_lexer (void); |
1826 | 397 |
16149
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16139
diff
changeset
|
398 void init (void); |
1826 | 399 |
16139
2fd39ab12209
move a function and data member from lexical_feedback to octave_parser
John W. Eaton <jwe@octave.org>
parents:
16130
diff
changeset
|
400 void reset (void); |
16122
6884401b2fbb
move reset_parser lexer helper function to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16120
diff
changeset
|
401 |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
402 void prep_for_file (void); |
16124
3be725cd195b
move more lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16122
diff
changeset
|
403 |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16194
diff
changeset
|
404 int read (char *buf, unsigned int max_size); |
16120
4b68eb9b98b0
move octave_read lexer helper function to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16118
diff
changeset
|
405 |
16164
c5bfdc4c0963
move end_of_input flag from octve_parser class to octave_lexer class
John W. Eaton <jwe@octave.org>
parents:
16158
diff
changeset
|
406 int handle_end_of_input (void); |
c5bfdc4c0963
move end_of_input flag from octve_parser class to octave_lexer class
John W. Eaton <jwe@octave.org>
parents:
16158
diff
changeset
|
407 |
16128
210039e91ad6
localize use of yytext with lexical_feedback member function
John W. Eaton <jwe@octave.org>
parents:
16126
diff
changeset
|
408 char *flex_yytext (void); |
210039e91ad6
localize use of yytext with lexical_feedback member function
John W. Eaton <jwe@octave.org>
parents:
16126
diff
changeset
|
409 |
16130
421dea028bbf
localize use of yyleng with lexical_feedback member function
John W. Eaton <jwe@octave.org>
parents:
16129
diff
changeset
|
410 int flex_yyleng (void); |
421dea028bbf
localize use of yyleng with lexical_feedback member function
John W. Eaton <jwe@octave.org>
parents:
16129
diff
changeset
|
411 |
16113
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
412 void do_comma_insert_check (void); |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
413 |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
414 int text_yyinput (void); |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
415 |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
416 void xunput (char c, char *buf); |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
417 |
16125
96a58f197f93
allow xunput to be called without buffer argument
John W. Eaton <jwe@octave.org>
parents:
16124
diff
changeset
|
418 void xunput (char c); |
96a58f197f93
allow xunput to be called without buffer argument
John W. Eaton <jwe@octave.org>
parents:
16124
diff
changeset
|
419 |
16113
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
420 void fixup_column_count (char *s); |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
421 |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
422 bool inside_any_object_index (void); |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
423 |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
424 int is_keyword_token (const std::string& s); |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
425 |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
426 bool is_variable (const std::string& name); |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
427 |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
428 std::string grab_block_comment (stream_reader& reader, bool& eof); |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
429 |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
430 std::string grab_comment_block (stream_reader& reader, bool at_bol, |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
431 bool& eof); |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
432 |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
433 int process_comment (bool start_in_block, bool& eof); |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
434 |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
435 bool next_token_is_sep_op (void); |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
436 |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
437 bool next_token_is_postfix_unary_op (bool spc_prev); |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
438 |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
439 bool next_token_is_bin_op (bool spc_prev); |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
440 |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
441 void scan_for_comments (const char *text); |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
442 |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
443 int eat_whitespace (void); |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
444 |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
445 void handle_number (void); |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
446 |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
447 bool have_continuation (bool trailing_comments_ok = true); |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
448 |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
449 bool have_ellipsis_continuation (bool trailing_comments_ok = true); |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
450 |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
451 int eat_continuation (void); |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
452 |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
453 int handle_string (char delim); |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
454 |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
455 bool next_token_is_assign_op (void); |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
456 |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
457 bool next_token_is_index_op (void); |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
458 |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
459 int handle_close_bracket (bool spc_gobbled, int bracket_type); |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
460 |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
461 void maybe_unput_comma (int spc_gobbled); |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
462 |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
463 bool next_token_can_follow_bin_op (void); |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
464 |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
465 bool looks_like_command_arg (void); |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
466 |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
467 int handle_superclass_identifier (void); |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
468 |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
469 int handle_meta_identifier (void); |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
470 |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
471 int handle_identifier (void); |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
472 |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
473 void maybe_warn_separator_insert (char sep); |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
474 |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
475 void gripe_single_quote_string (void); |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
476 |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
477 void gripe_matlab_incompatible (const std::string& msg); |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
478 |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
479 void maybe_gripe_matlab_incompatible_comment (char c); |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
480 |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
481 void gripe_matlab_incompatible_continuation (void); |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
482 |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
483 void gripe_matlab_incompatible_operator (const std::string& op); |
7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16111
diff
changeset
|
484 |
16126
5c885c13bfa3
localize use of yylval.tok_val in lexical_feedback member functions
John W. Eaton <jwe@octave.org>
parents:
16125
diff
changeset
|
485 void push_token (token *); |
5c885c13bfa3
localize use of yylval.tok_val in lexical_feedback member functions
John W. Eaton <jwe@octave.org>
parents:
16125
diff
changeset
|
486 |
5c885c13bfa3
localize use of yylval.tok_val in lexical_feedback member functions
John W. Eaton <jwe@octave.org>
parents:
16125
diff
changeset
|
487 token *current_token (void); |
5c885c13bfa3
localize use of yylval.tok_val in lexical_feedback member functions
John W. Eaton <jwe@octave.org>
parents:
16125
diff
changeset
|
488 |
16118
f8e463523229
move more static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16115
diff
changeset
|
489 void display_token (int tok); |
f8e463523229
move more static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16115
diff
changeset
|
490 |
16129
053b0364b507
localize use of yy_fatal_error with lexical_feedback member function
John W. Eaton <jwe@octave.org>
parents:
16128
diff
changeset
|
491 void fatal_error (const char *msg); |
053b0364b507
localize use of yy_fatal_error with lexical_feedback member function
John W. Eaton <jwe@octave.org>
parents:
16128
diff
changeset
|
492 |
16118
f8e463523229
move more static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16115
diff
changeset
|
493 void lexer_debug (const char *pattern, const char *text); |
f8e463523229
move more static lexer helper functions to lexical_feedback class
John W. Eaton <jwe@octave.org>
parents:
16115
diff
changeset
|
494 |
16149
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16139
diff
changeset
|
495 // Internal state of the flex-generated lexer. |
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16139
diff
changeset
|
496 void *scanner; |
49dfba4fd3c5
use pure parser and reentrant lexer interfaces
John W. Eaton <jwe@octave.org>
parents:
16139
diff
changeset
|
497 |
16183
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
498 // Object that reads and buffers input. |
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
499 input_buffer input_buf; |
359d56094efa
handle lexer input buffering with class
John W. Eaton <jwe@octave.org>
parents:
16164
diff
changeset
|
500 |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16194
diff
changeset
|
501 octave_input_reader input_reader; |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16194
diff
changeset
|
502 |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16194
diff
changeset
|
503 std::string input_source (void) const |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16194
diff
changeset
|
504 { |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16194
diff
changeset
|
505 return input_reader.input_source (); |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16194
diff
changeset
|
506 } |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16194
diff
changeset
|
507 |
16203
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
508 bool input_from_terminal (void) const |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
509 { |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
510 return input_source () == "terminal"; |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
511 } |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
512 |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
513 bool input_from_file (void) const |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
514 { |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
515 return input_source () == "file"; |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
516 } |
127cccb037bf
move more global parser and lexer variables to classes
John W. Eaton <jwe@octave.org>
parents:
16199
diff
changeset
|
517 |
16195
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16194
diff
changeset
|
518 bool input_from_eval_string (void) const |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16194
diff
changeset
|
519 { |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16194
diff
changeset
|
520 return input_source () == "eval_string"; |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16194
diff
changeset
|
521 } |
b52d2f9294b6
use class for reading lexer input
John W. Eaton <jwe@octave.org>
parents:
16194
diff
changeset
|
522 |
16126
5c885c13bfa3
localize use of yylval.tok_val in lexical_feedback member functions
John W. Eaton <jwe@octave.org>
parents:
16125
diff
changeset
|
523 // For unwind protect. |
16158
7eb614760ddb
rename lexical_feedback to octave_lexer
John W. Eaton <jwe@octave.org>
parents:
16149
diff
changeset
|
524 static void cleanup (octave_lexer *lexer) { delete lexer; } |
16126
5c885c13bfa3
localize use of yylval.tok_val in lexical_feedback member functions
John W. Eaton <jwe@octave.org>
parents:
16125
diff
changeset
|
525 |
5c885c13bfa3
localize use of yylval.tok_val in lexical_feedback member functions
John W. Eaton <jwe@octave.org>
parents:
16125
diff
changeset
|
526 private: |
5c885c13bfa3
localize use of yylval.tok_val in lexical_feedback member functions
John W. Eaton <jwe@octave.org>
parents:
16125
diff
changeset
|
527 |
16110
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16107
diff
changeset
|
528 // No copying! |
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16107
diff
changeset
|
529 |
16158
7eb614760ddb
rename lexical_feedback to octave_lexer
John W. Eaton <jwe@octave.org>
parents:
16149
diff
changeset
|
530 octave_lexer (const octave_lexer&); |
16110
7302f8a4df83
use pointer for global lexical_feedback structure
John W. Eaton <jwe@octave.org>
parents:
16107
diff
changeset
|
531 |
16158
7eb614760ddb
rename lexical_feedback to octave_lexer
John W. Eaton <jwe@octave.org>
parents:
16149
diff
changeset
|
532 octave_lexer& operator = (const octave_lexer&); |
1826 | 533 }; |
534 | |
1 | 535 #endif |