mirror of
https://github.com/yhirose/cpp-peglib.git
synced 2024-12-23 04:15:31 +00:00
Updated documentation.
This commit is contained in:
parent
59cb3b5aea
commit
feff9d1d97
16
README.md
16
README.md
@ -89,6 +89,11 @@ struct SemanticValue {
|
||||
std::string name; // Definition name for the sematic value
|
||||
const char* s; // Token start for the semantic value
|
||||
size_t n; // Token length for the semantic value
|
||||
|
||||
// Utility method
|
||||
template <typename T> T& get();
|
||||
template <typename T> const T& get() const;
|
||||
std::string str() const;
|
||||
};
|
||||
|
||||
struct SemanticValues : protected std::vector<SemanticValue>
|
||||
@ -96,6 +101,17 @@ struct SemanticValues : protected std::vector<SemanticValue>
|
||||
const char* s; // Token start
|
||||
size_t n; // Token length
|
||||
size_t choice; // Choice number (0 based index)
|
||||
|
||||
using std::vector<T>::size;
|
||||
using std::vector<T>::operator[];
|
||||
using std::vector<T>::begin;
|
||||
using std::vector<T>::end;
|
||||
// NOTE: There are more std::vector methods available...
|
||||
|
||||
// Transform the semantice values vector to another vector
|
||||
template <typename F> auto map(size_t beg, size_t end, F f) const -> vector<typename std::remove_const<decltype(f(SemanticValue()))>::type>;
|
||||
template <typename F> auto map(F f) const -> vector<typename std::remove_const<decltype(f(SemanticValue()))>::type>;
|
||||
template <typename T> auto map(size_t beg = 0, size_t end = -1) const -> vector<T>;
|
||||
}
|
||||
```
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user