Mercurial > hg > octave-lyh
annotate libinterp/parse-tree/pt-unop.h @ 16253:a89cf57ba3a5
partial cleanup of continuation handling in lexer
* lex.h, lex.ll (octave_lexer::handle_continuation): New function.
(octave_lexer::finish_comment): Move to octave_lexer::finish_comment.
Don't return token. New argument, looking_at_continuation. If not
handling continuation, unput newline character.
(^{S}*{CCHAR}\{{S}*{NL}): Call yyless before finishing comment.
(^{S}*{CCHAR}\{{S}*{NL}, <BLOCK_COMMENT_START>^{S}*{CCHAR}\{{S}*{NL},
<LINE_COMMENT_START>{ANY_INCLUDING_NL},
<LINE_COMMENT_START>{S}*{CCHAR}.*{NL}): Don't return token.
(<LINE_COMMENT_START>{S}*{CCHAR}.*{NL}): Don't give COMMAND_START
start state special treatment.
({CONT}{S}*{NL}|{CONT}{S}*{COMMENT}):
Call octave_lexer::handle_continuation.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 09 Mar 2013 21:44:14 -0500 |
parents | 2fc554ffbc28 |
children |
rev | line source |
---|---|
2980 | 1 /* |
2 | |
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
3 Copyright (C) 1996-2012 John W. Eaton |
2980 | 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. | |
2980 | 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/>. | |
2980 | 20 |
21 */ | |
22 | |
23 #if !defined (octave_tree_unop_h) | |
24 #define octave_tree_unop_h 1 | |
25 | |
26 #include <string> | |
27 | |
28 class tree_walker; | |
29 | |
30 class octave_value; | |
31 class octave_value_list; | |
32 class octave_lvalue; | |
33 | |
34 #include "pt-exp.h" | |
7336 | 35 #include "symtab.h" |
2980 | 36 |
37 // Unary expressions. | |
38 | |
39 class | |
40 tree_unary_expression : public tree_expression | |
41 { | |
42 public: | |
43 | |
3203 | 44 tree_unary_expression (int l = -1, int c = -1, |
10313 | 45 octave_value::unary_op t |
46 = octave_value::unknown_unary_op) | |
3203 | 47 : tree_expression (l, c), op (0), etype (t) { } |
2980 | 48 |
3203 | 49 tree_unary_expression (tree_expression *e, int l = -1, int c = -1, |
10313 | 50 octave_value::unary_op t |
51 = octave_value::unknown_unary_op) | |
3203 | 52 : tree_expression (l, c), op (e), etype (t) { } |
2980 | 53 |
54 ~tree_unary_expression (void) { delete op; } | |
55 | |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7767
diff
changeset
|
56 bool is_unary_expression (void) const { return true; } |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7767
diff
changeset
|
57 |
4267 | 58 bool has_magic_end (void) const { return (op && op->has_magic_end ()); } |
59 | |
2980 | 60 tree_expression *operand (void) { return op; } |
61 | |
3523 | 62 std::string oper (void) const; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
63 |
7087 | 64 octave_value::unary_op op_type (void) const { return etype; } |
3203 | 65 |
2980 | 66 protected: |
67 | |
68 // The operand for the expression. | |
69 tree_expression *op; | |
2988 | 70 |
3203 | 71 // The type of the expression. |
72 octave_value::unary_op etype; | |
73 | |
74 private: | |
75 | |
2988 | 76 // No copying! |
77 | |
78 tree_unary_expression (const tree_unary_expression&); | |
79 | |
80 tree_unary_expression& operator = (const tree_unary_expression&); | |
2980 | 81 }; |
82 | |
83 // Prefix expressions. | |
84 | |
85 class | |
86 tree_prefix_expression : public tree_unary_expression | |
87 { | |
88 public: | |
89 | |
90 tree_prefix_expression (int l = -1, int c = -1) | |
3203 | 91 : tree_unary_expression (l, c, octave_value::unknown_unary_op) { } |
2980 | 92 |
3195 | 93 tree_prefix_expression (tree_expression *e, int l = -1, int c = -1, |
10313 | 94 octave_value::unary_op t |
95 = octave_value::unknown_unary_op) | |
3203 | 96 : tree_unary_expression (e, l, c, t) { } |
2980 | 97 |
98 ~tree_prefix_expression (void) { } | |
99 | |
3933 | 100 bool rvalue_ok (void) const { return true; } |
2980 | 101 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
102 octave_value rvalue1 (int nargout = 1); |
2980 | 103 |
3010 | 104 octave_value_list rvalue (int nargout); |
2980 | 105 |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
106 tree_expression *dup (symbol_table::scope_id scope, |
10313 | 107 symbol_table::context_id context) const; |
5861 | 108 |
2980 | 109 void accept (tree_walker& tw); |
110 | |
111 private: | |
112 | |
2988 | 113 // No copying! |
114 | |
115 tree_prefix_expression (const tree_prefix_expression&); | |
116 | |
117 tree_prefix_expression& operator = (const tree_prefix_expression&); | |
2980 | 118 }; |
119 | |
120 // Postfix expressions. | |
121 | |
122 class | |
123 tree_postfix_expression : public tree_unary_expression | |
124 { | |
125 public: | |
126 | |
127 tree_postfix_expression (int l = -1, int c = -1) | |
3203 | 128 : tree_unary_expression (l, c, octave_value::unknown_unary_op) { } |
2980 | 129 |
3195 | 130 tree_postfix_expression (tree_expression *e, int l = -1, int c = -1, |
10313 | 131 octave_value::unary_op t |
132 = octave_value::unknown_unary_op) | |
3203 | 133 : tree_unary_expression (e, l, c, t) { } |
2980 | 134 |
135 ~tree_postfix_expression (void) { } | |
136 | |
3933 | 137 bool rvalue_ok (void) const { return true; } |
2980 | 138 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
139 octave_value rvalue1 (int nargout = 1); |
2980 | 140 |
141 octave_value_list rvalue (int nargout); | |
142 | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
143 tree_expression *dup (symbol_table::scope_id scope, |
10313 | 144 symbol_table::context_id context) const; |
5861 | 145 |
2980 | 146 void accept (tree_walker& tw); |
147 | |
148 private: | |
149 | |
2988 | 150 // No copying! |
151 | |
152 tree_postfix_expression (const tree_postfix_expression&); | |
153 | |
154 tree_postfix_expression& operator = (const tree_postfix_expression&); | |
2980 | 155 }; |
156 | |
157 #endif |