Mercurial > hg > octave-nkf
annotate libinterp/parse-tree/pt-const.cc @ 18588:932aca9a7c57
Allow multi-level classdef package.
* lex.h (octave_base_lexer::fq_identifier_contains_keyword,
octave_base_lexer::handle_fq_identifier,
octave_base_lexer::enable_fq_identifier): New methods.
* lex.ll (octave_base_lexer::fq_identifier_contains_keyword,
octave_base_lexer::handle_fq_identifier,
octave_base_lexer::enable_fq_identifier): Likewise.
(FQ_IDENT_START, FQIDENT): New exclusive start condition and regex to
handle fully-qualified identifier.
(superclass reference rule, metaclass query rule): Use FQIDENT.
(octave_base_lexer::handle_superclass_identifier,
octave_base_lexer::handle_meta_identifier): Don't split package name.
* parse.h (octave_base_parser::make_superclass_ref,
octave_base_parser::make_meta_class_query): Remove package_nm argument.
* pt-classdef.h (tree_classdef_superclass::id,
tree_classdef_superclass::pkg): Removed members, replaced by cls_name.
(tree_classdef_superclass::~tree_classdef_superclass): Remove deletion
of removed members.
(tree_classdef_superclass::cls_name): New member.
(tree_classdef_superclass::tree_classdef_superclass): Initialize it.
(tree_classdef_superclass::ident, tree_classdef_superclass::package):
Removed methods.
(tree_classdef_superclass::class_name): New method.
* token.h (token::meta_name_token): Remove enum value.
(token(int, std::string, std::string, std::string, int, int)): Remove
constructor.
(token::superclass_package_name, token::meta_package_name,
token::meta_class_name): Remove methods.
(token::sc::package_nm, token::mc): Remove union members.
* token.cc
(token(int, std::string, std::string, std::string, int, int)): Remove
constructor.
(token::~token): Remove case of meta_name_token.
(token::superclass_package_name, token::meta_package_name,
token::meta_class_name): Remove methods.
* oct-parse.in.yy (FQ_IDENT): New terminal.
(superclass_identifier): Adapt to changes in class token and class
octave_base_parser.
(meta_identifier): Likewise.
(superclass_list): Add mid-rule to enable fully-qualified identifier.
(superclass): Use FQ_IDENT.
(octave_base_parser::make_superclass_ref,
octave_base_parser::make_meta_class_query): Remove package_nm argument.
* ov-classdef.cc (octave_classdef_superclass_ref::do_multi_index_op):
Adapt to removal of package_nm argument.
(F__meta_class_query__): Likewise.
(cdef_class::make_meta_class): Adapt to changes in class
tree_classdef_superclass.
author | Michael Goffioul <michael.goffioul@gmail.com> |
---|---|
date | Sat, 22 Feb 2014 19:56:17 -0500 |
parents | 175b392e91fe |
children | 76478d2da117 |
rev | line source |
---|---|
1 | 1 /* |
2 | |
17744
d63878346099
maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
3 Copyright (C) 1993-2013 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 | |
240 | 23 #ifdef HAVE_CONFIG_H |
1192 | 24 #include <config.h> |
1 | 25 #endif |
26 | |
3503 | 27 #include <iostream> |
581 | 28 |
2971 | 29 #include "error.h" |
1742 | 30 #include "oct-obj.h" |
2900 | 31 #include "pager.h" |
1742 | 32 #include "pt-const.h" |
2124 | 33 #include "pt-walk.h" |
1558 | 34 |
2477 | 35 // We are likely to have a lot of tree_constant objects to allocate, |
36 // so make the grow_size large. | |
13969
3b5afcec526b
* pt-const.h, pt-const.cc: Use macros to declare and define octave_allocator.
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
37 DEFINE_OCTAVE_ALLOCATOR2 (tree_constant, 1024); |
2475 | 38 |
2532 | 39 void |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
40 tree_constant::print (std::ostream& os, bool pr_as_read_syntax, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
41 bool pr_orig_text) |
2532 | 42 { |
43 if (pr_orig_text && ! orig_text.empty ()) | |
44 os << orig_text; | |
45 else | |
46 val.print (os, pr_as_read_syntax); | |
47 } | |
48 | |
2942 | 49 void |
3523 | 50 tree_constant::print_raw (std::ostream& os, bool pr_as_read_syntax, |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
51 bool pr_orig_text) |
2942 | 52 { |
53 if (pr_orig_text && ! orig_text.empty ()) | |
54 os << orig_text; | |
55 else | |
56 val.print_raw (os, pr_as_read_syntax); | |
57 } | |
58 | |
2971 | 59 octave_value_list |
60 tree_constant::rvalue (int nargout) | |
2390 | 61 { |
2971 | 62 octave_value_list retval; |
2390 | 63 |
2971 | 64 if (nargout > 1) |
65 error ("invalid number of output arguments for constant expression"); | |
66 else | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
67 retval = rvalue1 (nargout); |
2390 | 68 |
2971 | 69 return retval; |
2532 | 70 } |
71 | |
5861 | 72 tree_expression * |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
73 tree_constant::dup (symbol_table::scope_id, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
74 symbol_table::context_id) const |
5861 | 75 { |
76 tree_constant *new_tc | |
77 = new tree_constant (val, orig_text, line (), column ()); | |
78 | |
79 new_tc->copy_base (*this); | |
80 | |
81 return new_tc; | |
82 } | |
83 | |
2532 | 84 void |
2390 | 85 tree_constant::accept (tree_walker& tw) |
86 { | |
87 tw.visit_constant (*this); | |
88 } |