Skip to content

Commit 8e618a0

Browse files
authored
Merge pull request #87 from TheJJ/dict-abstract-optional-inf-children
new features: dict, abstract, optional, children and infinity
2 parents 2cfcebc + c972a37 commit 8e618a0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+4697
-953
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,17 @@ __pycache__
2424
/bin
2525
/.bin
2626
/build
27+
/compile_commands.json
2728

2829
# debugging
2930
callgrind.out.*
3031
perf.data*
3132
.gdb_history
3233

34+
# IDE stuff
35+
/.cache
36+
/.dir-locals.el
37+
3338
# cmake in-source builds
3439
/DartConfiguration.tcl
3540
/Testing

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2017-2017 the nyan authors. See copying.md for legal info.
1+
# Copyright 2017-2021 the nyan authors. See copying.md for legal info.
22

33
# main nyan build configuration file
44

@@ -36,7 +36,7 @@ project(nyan VERSION ${nyan_VERSION} LANGUAGES CXX)
3636
set(nyan_exports_name "nyanTargets")
3737

3838
# C++ standard requirement
39-
set(CMAKE_CXX_STANDARD 17)
39+
set(CMAKE_CXX_STANDARD 20)
4040
set(CMAKE_CXX_STANDARD_REQUIRED ON)
4141

4242
# CMake policies

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ The foundation of **nyan**:
2121

2222
Technology | Component
2323
-----------------------|----------
24-
**C++17** | nyan core
24+
**C++20** | nyan core
2525
**Flex** | Tokenizer generator
2626
**CMake** | Build "system"
2727
**Humans** | Doing it wrong all the time

doc/member_types.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,8 @@ the set type.
348348

349349
`set` does not preserve the input order of items.
350350

351+
A `set` element type can't be optional.
352+
351353

352354
```python
353355
OtherObject():
@@ -420,6 +422,7 @@ the set type.
420422

421423
`orderedset` does preserve the input order of items.
422424

425+
The `orderedset` element type can't be optional.
423426

424427
```python
425428
OtherObject():
@@ -486,6 +489,9 @@ A member with type `dict` can store a collection of key-value pairs.
486489
Both the key type and value type must be specified during the member declaration.
487490
Dicts cannot contain items with duplicate keys. They can be empty.
488491

492+
Dict keys can't be `optional`.
493+
494+
489495
```python
490496
OtherObject():
491497
pass

kevinfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
#
55

66
configure:
7+
- env: compiler=g++ (? if job == "debian" ?)
8+
- env: compiler=clang++ (? if job == "debian-clang" ?)
79
mkdir build
8-
cd build && cmake ..
10+
cd build && cmake .. -DCMAKE_CXX_COMPILER=${compiler}
911

1012
build: configure
1113
- cwd: build/

nyan/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,13 @@ add_library(nyan SHARED
6565
transaction.cpp
6666
type.cpp
6767
util.cpp
68+
util/flags.cpp
69+
value_token.cpp
6870
value/boolean.cpp
6971
value/container.cpp
72+
value/dict.cpp
7073
value/file.cpp
74+
value/none.cpp
7175
value/number.cpp
7276
value/object.cpp
7377
value/orderedset.cpp
@@ -119,7 +123,7 @@ install(
119123
EXPORT ${nyan_exports_name}
120124
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
121125
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
122-
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}
126+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
123127
)
124128

125129
# install headers

nyan/api_error.cpp

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2019-2019 the nyan authors, LGPLv3+. See copying.md for legal info.
1+
// Copyright 2019-2021 the nyan authors, LGPLv3+. See copying.md for legal info.
22

33
#include "api_error.h"
44

@@ -7,41 +7,37 @@
77

88
namespace nyan {
99

10-
APIError::APIError(const std::string &msg)
11-
:
10+
APIError::APIError(const std::string &msg) :
1211
Error{msg} {}
1312

1413

15-
InvalidObjectError::InvalidObjectError()
16-
:
14+
InvalidObjectError::InvalidObjectError() :
1715
APIError("uninitialized object was used") {}
1816

1917

20-
MemberTypeError::MemberTypeError(const fqon_t &objname, const memberid_t &member,
21-
const std::string &real_type, const std::string &wrong_type)
22-
:
23-
APIError{
24-
(static_cast<const std::ostringstream&>(
25-
std::ostringstream{} << "type mismatch for member " << objname + "." << member
26-
<< ": tried to convert real type " << real_type << " to " << wrong_type)
27-
).str()},
28-
name{objname},
18+
MemberTypeError::MemberTypeError(const fqon_t &objname,
19+
const memberid_t &member,
20+
const std::string &real_type,
21+
const std::string &wrong_type) :
22+
APIError{(static_cast<const std::ostringstream &>(
23+
std::ostringstream{} << "type mismatch for member " << objname + "." << member
24+
<< ": tried to convert real type " << real_type << " to " << wrong_type))
25+
.str()},
26+
objname{objname},
2927
member{member},
3028
real_type{real_type},
3129
wrong_type{wrong_type} {}
3230

3331

34-
ObjectNotFoundError::ObjectNotFoundError(const fqon_t &obj_name)
35-
:
32+
ObjectNotFoundError::ObjectNotFoundError(const fqon_t &obj_name) :
3633
APIError{"object not found: " + obj_name},
37-
name{obj_name} {}
34+
objname{obj_name} {}
3835

3936

4037
MemberNotFoundError::MemberNotFoundError(const fqon_t &obj_name,
41-
const memberid_t &member_name)
42-
:
38+
const memberid_t &member_name) :
4339
APIError{"Could not find member " + obj_name + "." + member_name},
44-
obj_name{obj_name},
40+
objname{obj_name},
4541
name{member_name} {}
4642

4743
} // namespace nyan

nyan/api_error.h

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2019-2019 the nyan authors, LGPLv3+. See copying.md for legal info.
1+
// Copyright 2019-2021 the nyan authors, LGPLv3+. See copying.md for legal info.
22
#pragma once
33

44
#include "error.h"
@@ -35,9 +35,24 @@ class MemberTypeError : public APIError {
3535
const std::string &real_type, const std::string &wrong_type);
3636

3737
protected:
38-
fqon_t name;
38+
/**
39+
* Name (identifier) of the object the member is part of.
40+
*/
41+
fqon_t objname;
42+
43+
/**
44+
* Name (identifier) of the member.
45+
*/
3946
memberid_t member;
47+
48+
/**
49+
* Type that the member should have assigned.
50+
*/
4051
std::string real_type;
52+
53+
/**
54+
* Type that the member has actually assigned.
55+
*/
4156
std::string wrong_type;
4257
};
4358

@@ -50,7 +65,10 @@ class ObjectNotFoundError : public APIError {
5065
ObjectNotFoundError(const fqon_t &objname);
5166

5267
protected:
53-
fqon_t name;
68+
/**
69+
* Name (identifier) of the object.
70+
*/
71+
fqon_t objname;
5472
};
5573

5674

@@ -63,7 +81,14 @@ class MemberNotFoundError : public APIError {
6381
const memberid_t &membername);
6482

6583
protected:
66-
fqon_t obj_name;
84+
/**
85+
* Name (identifier) of the object the member is part of.
86+
*/
87+
fqon_t objname;
88+
89+
/**
90+
* Name (identifier) of the member.
91+
*/
6792
memberid_t name;
6893
};
6994

0 commit comments

Comments
 (0)