1 /*
2     This file is part of GNU APL, a free implementation of the
3     ISO/IEC Standard 13751, "Programming Language APL, Extended"
4 
5     Copyright (C) 2008-2015  Dr. Jürgen Sauermann
6 
7     This program is free software: you can redistribute it and/or modify
8     it under the terms of the GNU General Public License as published by
9     the Free Software Foundation, either version 3 of the License, or
10     (at your option) any later version.
11 
12     This program is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15     GNU General Public License for more details.
16 
17     You should have received a copy of the GNU General Public License
18     along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 #ifndef __ID_HH_DEFINED__
22 #define __ID_HH_DEFINED__
23 
24 #include <iostream>
25 
26 #include "UTF8_string.hh"
27 #include "UCS_string.hh"
28 
29 class Function;
30 class Symbol;
31 class UCS_string;
32 
33 //-----------------------------------------------------------------------------
34 /**
35  An Identifier for each internal object (primitives, Quad-symbols, and more).
36  The ID can be derived in different ways:
37 
38  1. from a (user0defined) name,       e.g.  ID_APL_VALUE or ID_CHARACTER
39  2. from a distinguished var name,    e.g.  ID_Quad_AI or ID_Quad_AV
40  3. from a distinguished fun name,    e.g.  ID_Quad_AT or ID_Quad_EM
41  4. from a special token (apl symbol) e.g.  ID_L_PARENT1 or ID_ASSIGN
42 
43   This is controlled by 5 corresponding macros: pp() qv() qf() resp. st()
44  */
45 /// Identifier of an internal object of the APL interpreter
46 class ID
47 {
48 public:
49    /// return the printable name for id as UTF8 *
50    static const UTF8 * get_name(Id id);
51 
52    /// return the printable name for id as UCS_string
53    static UCS_string get_name_UCS(Id id);
54 
55    /// If \b id is the ID of primitive function, primitive operator, or
56    /// quad function, then return a pointer to it. Otherwise return 0.
57    static Function * get_system_function(Id id);
58 
59    /// If \b id is the ID of a quad variable, then return a pointer to its
60    /// symbol. Otherwise return 0.
61    static Symbol * get_system_variable(Id id);
62 
63    /// return the TokenTag for \b id
64    static int get_token_tag(Id id);
65 
66    /// release UCS_strings with ID names
67    static void cleanup();
68 };
69 //-----------------------------------------------------------------------------
70 
71 #include "TokenEnums.hh"
72 
73 #endif // __ID_HH_DEFINED__
74 
75