Skip to content

Commit

Permalink
Merge pull request #87 from TheJJ/dict-abstract-optional-inf-children
Browse files Browse the repository at this point in the history
new features: dict, abstract, optional, children and infinity
  • Loading branch information
TheJJ authored Aug 20, 2021
2 parents 2cfcebc + c972a37 commit 8e618a0
Show file tree
Hide file tree
Showing 121 changed files with 4,697 additions and 953 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,17 @@ __pycache__
/bin
/.bin
/build
/compile_commands.json

# debugging
callgrind.out.*
perf.data*
.gdb_history

# IDE stuff
/.cache
/.dir-locals.el

# cmake in-source builds
/DartConfiguration.tcl
/Testing
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2017-2017 the nyan authors. See copying.md for legal info.
# Copyright 2017-2021 the nyan authors. See copying.md for legal info.

# main nyan build configuration file

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

# C++ standard requirement
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# CMake policies
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The foundation of **nyan**:

Technology | Component
-----------------------|----------
**C++17** | nyan core
**C++20** | nyan core
**Flex** | Tokenizer generator
**CMake** | Build "system"
**Humans** | Doing it wrong all the time
Expand Down
6 changes: 6 additions & 0 deletions doc/member_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,8 @@ the set type.

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

A `set` element type can't be optional.


```python
OtherObject():
Expand Down Expand Up @@ -420,6 +422,7 @@ the set type.

`orderedset` does preserve the input order of items.

The `orderedset` element type can't be optional.

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

Dict keys can't be `optional`.


```python
OtherObject():
pass
Expand Down
4 changes: 3 additions & 1 deletion kevinfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
#

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

build: configure
- cwd: build/
Expand Down
6 changes: 5 additions & 1 deletion nyan/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,13 @@ add_library(nyan SHARED
transaction.cpp
type.cpp
util.cpp
util/flags.cpp
value_token.cpp
value/boolean.cpp
value/container.cpp
value/dict.cpp
value/file.cpp
value/none.cpp
value/number.cpp
value/object.cpp
value/orderedset.cpp
Expand Down Expand Up @@ -119,7 +123,7 @@ install(
EXPORT ${nyan_exports_name}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

# install headers
Expand Down
36 changes: 16 additions & 20 deletions nyan/api_error.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019-2019 the nyan authors, LGPLv3+. See copying.md for legal info.
// Copyright 2019-2021 the nyan authors, LGPLv3+. See copying.md for legal info.

#include "api_error.h"

Expand All @@ -7,41 +7,37 @@

namespace nyan {

APIError::APIError(const std::string &msg)
:
APIError::APIError(const std::string &msg) :
Error{msg} {}


InvalidObjectError::InvalidObjectError()
:
InvalidObjectError::InvalidObjectError() :
APIError("uninitialized object was used") {}


MemberTypeError::MemberTypeError(const fqon_t &objname, const memberid_t &member,
const std::string &real_type, const std::string &wrong_type)
:
APIError{
(static_cast<const std::ostringstream&>(
std::ostringstream{} << "type mismatch for member " << objname + "." << member
<< ": tried to convert real type " << real_type << " to " << wrong_type)
).str()},
name{objname},
MemberTypeError::MemberTypeError(const fqon_t &objname,
const memberid_t &member,
const std::string &real_type,
const std::string &wrong_type) :
APIError{(static_cast<const std::ostringstream &>(
std::ostringstream{} << "type mismatch for member " << objname + "." << member
<< ": tried to convert real type " << real_type << " to " << wrong_type))
.str()},
objname{objname},
member{member},
real_type{real_type},
wrong_type{wrong_type} {}


ObjectNotFoundError::ObjectNotFoundError(const fqon_t &obj_name)
:
ObjectNotFoundError::ObjectNotFoundError(const fqon_t &obj_name) :
APIError{"object not found: " + obj_name},
name{obj_name} {}
objname{obj_name} {}


MemberNotFoundError::MemberNotFoundError(const fqon_t &obj_name,
const memberid_t &member_name)
:
const memberid_t &member_name) :
APIError{"Could not find member " + obj_name + "." + member_name},
obj_name{obj_name},
objname{obj_name},
name{member_name} {}

} // namespace nyan
33 changes: 29 additions & 4 deletions nyan/api_error.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019-2019 the nyan authors, LGPLv3+. See copying.md for legal info.
// Copyright 2019-2021 the nyan authors, LGPLv3+. See copying.md for legal info.
#pragma once

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

protected:
fqon_t name;
/**
* Name (identifier) of the object the member is part of.
*/
fqon_t objname;

/**
* Name (identifier) of the member.
*/
memberid_t member;

/**
* Type that the member should have assigned.
*/
std::string real_type;

/**
* Type that the member has actually assigned.
*/
std::string wrong_type;
};

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

protected:
fqon_t name;
/**
* Name (identifier) of the object.
*/
fqon_t objname;
};


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

protected:
fqon_t obj_name;
/**
* Name (identifier) of the object the member is part of.
*/
fqon_t objname;

/**
* Name (identifier) of the member.
*/
memberid_t name;
};

Expand Down
Loading

0 comments on commit 8e618a0

Please sign in to comment.