annotate libinterp/parse-tree/pt-funcall.h @ 20624:7c0e10f035bd

Extend parser to accept binary constants that begin with '0b' or '0B'. * NEWS: Announce change: * lex.ll: Define NUMBIN to be 0[bB] followed by 0,1, or '_'. Define NUMBER to be NUMREAL|NUMHEX|NUMBIN. *lex.ll (looks_like_bin): New function to detect 0[bB] prefix. *lex.ll (handle_numbe): Call looks_like_bin() and if found then convert binary string to double. * parser.tst: Add tests for new behavior.
author Rik <rik@octave.org>
date Fri, 09 Oct 2015 18:52:58 -0700
parents 4197fc428c7d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15035
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1 /*
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2
19731
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 18355
diff changeset
3 Copyright (C) 2012-2015 John W. Eaton
15035
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
4
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
5 This file is part of Octave.
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
6
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
10 option) any later version.
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
11
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
15 for more details.
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
16
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
18 along with Octave; see the file COPYING. If not, see
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
19 <http://www.gnu.org/licenses/>.
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
20
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
21 */
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
22
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
23 #if !defined (octave_tree_funcall_h)
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
24 #define octave_tree_funcall_h 1
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26 #include "ov.h"
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27 #include "oct-obj.h"
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28 #include "parse.h"
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29 #include "pt-exp.h"
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
31 // Function call. This class only represents function calls that have
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32 // known functions (most useful for calls to built-in functions that
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33 // are generated by the parser) and fixed argument lists, known at
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34 // compile time.
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
36 class
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37 tree_funcall : public tree_expression
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38 {
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39 public:
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41 tree_funcall (const octave_value& f, const octave_value_list& a,
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
42 int l = -1, int c = -1)
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43 : tree_expression (l, c), fcn (f), args (a)
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
44 {
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
45 if (! fcn.is_function ())
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
46 error ("tree_funcall: invalid function");
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
47 }
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
48
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
49 ~tree_funcall (void) { }
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
50
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
51 bool has_magic_end (void) const { return false; }
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
52
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
53 void print (std::ostream& os, bool pr_as_read_syntax = false,
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
54 bool pr_orig_txt = true);
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
55
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
56 void print_raw (std::ostream& os, bool pr_as_read_syntax = false,
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
57 bool pr_orig_txt = true);
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
58
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
59 tree_funcall *dup (symbol_table::scope_id,
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
60 symbol_table::context_id context) const;
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
61
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
62 octave_value rvalue1 (int nargout)
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
63 {
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
64 octave_value retval;
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
65
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
66 const octave_value_list tmp = rvalue (nargout);
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
67
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
68 if (! tmp.empty ())
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
69 retval = tmp(0);
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
70
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
71 return retval;
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
72 }
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
73
18355
9ca314e79956 Allow to call superclass constructor without arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17746
diff changeset
74 octave_value_list rvalue (int nargout);
15035
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
75
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
76 octave_value function (void) const { return fcn; }
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
77
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
78 octave_value_list arguments (void) const { return args; }
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
79
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
80 void accept (tree_walker& tw);
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
81
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
82 private:
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
83
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
84 // Function to call. Error if not a valid function at time of
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
85 // construction.
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
86 octave_value fcn;
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
87
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
88 // Argument list.
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
89 octave_value_list args;
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
90
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
91 // No copying!
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
92
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
93 tree_funcall (const tree_funcall&);
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
94
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
95 tree_funcall& operator = (const tree_funcall&);
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
96 };
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
97
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
98 #endif