IDL compiler front-end library
Loading...
Searching...
No Matches
Declarators.h
Go to the documentation of this file.
1
2/*
3* Nirvana IDL front-end library.
4*
5* This is a part of the Nirvana project.
6*
7* Author: Igor Popov
8*
9* Copyright (c) 2021 Igor Popov.
10*
11* This program is free software; you can redistribute it and/or modify
12* it under the terms of the GNU Lesser General Public License as published by
13* the Free Software Foundation; either version 3 of the License, or
14* (at your option) any later version.
15*
16* This program is distributed in the hope that it will be useful,
17* but WITHOUT ANY WARRANTY; without even the implied warranty of
18* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19* GNU General Public License for more details.
20*
21* You should have received a copy of the GNU Lesser General Public
22* License along with this library. If not, see <http://www.gnu.org/licenses/>.
23*
24* Send comments and/or bug reports to:
25* popov.nirvana@gmail.com
26*/
27#ifndef IDLFE_AST_DECLARATORS_H_
28#define IDLFE_AST_DECLARATORS_H_
29#pragma once
30
31#include "Identifier.h"
32#include "Location.h"
33#include <forward_list>
34
35namespace AST {
36
39 public Identifier,
40 public Location
41{
42public:
44 {}
45
50 SimpleDeclarator (const Identifier& name, const Location& loc) :
51 Identifier (name),
52 Location (loc)
53 {}
54
59 SimpleDeclarator (Identifier&& name, const Location& loc) :
60 Identifier (std::move (name)),
61 Location (loc)
62 {}
63
64 SimpleDeclarator (const SimpleDeclarator&) = default;
66
67 SimpleDeclarator& operator = (const SimpleDeclarator&) = default;
68 SimpleDeclarator& operator = (SimpleDeclarator&&) = default;
69};
70
72typedef std::forward_list <SimpleDeclarator> SimpleDeclarators;
73
75typedef std::forward_list <unsigned> FixedArraySizes;
76
79 public SimpleDeclarator
80{
81public:
82 Declarator ()
83 {}
84
90 Declarator (const Identifier& name, const Location& loc, const FixedArraySizes& array) :
91 SimpleDeclarator (name, loc),
92 array_ (array)
93 {}
94
100 Declarator (Identifier&& name, const Location& loc, const FixedArraySizes& array) :
101 SimpleDeclarator (std::move (name), loc),
102 array_ (array)
103 {}
104
109 Declarator (const Identifier& name, const Location& loc) :
110 SimpleDeclarator (name, loc)
111 {}
112
117 Declarator (Identifier&& name, const Location& loc) :
118 SimpleDeclarator (std::move (name), loc)
119 {}
120
121 Declarator (const SimpleDeclarator& decl) :
122 SimpleDeclarator (decl)
123 {}
124
125 Declarator (SimpleDeclarator&& decl) :
126 SimpleDeclarator (std::move (decl))
127 {}
128
129 Declarator (const Declarator&) = default;
130 Declarator (Declarator&&) = default;
131
132 Declarator& operator = (const Declarator&) = default;
133 Declarator& operator = (Declarator&&) = default;
134
137 {
138 return array_;
139 }
140
141private:
142 FixedArraySizes array_;
143};
144
146typedef std::forward_list <Declarator> Declarators;
147
148}
149
150#endif
The IDL declarator.
Definition Declarators.h:80
Declarator(Identifier &&name, const Location &loc)
Declarator(const Identifier &name, const Location &loc)
const FixedArraySizes & array_sizes() const
Declarator(Identifier &&name, const Location &loc, const FixedArraySizes &array)
Declarator(const Identifier &name, const Location &loc, const FixedArraySizes &array)
Definition Declarators.h:90
An identifier.
Definition Identifier.h:37
Stores the location information.
Definition Location.h:43
The IDL simple declarator.
Definition Declarators.h:41
SimpleDeclarator(const Identifier &name, const Location &loc)
Definition Declarators.h:50
SimpleDeclarator(Identifier &&name, const Location &loc)
Definition Declarators.h:59
Abstract Syntax Tree namespace.
Definition Array.h:34
std::forward_list< SimpleDeclarator > SimpleDeclarators
The IDL simple declarators.
Definition Declarators.h:72
std::forward_list< unsigned > FixedArraySizes
Array dimensions.
Definition Declarators.h:75
std::forward_list< Declarator > Declarators
The IDL declarators.