BehaviorTree
Core Library to create and execute Behavior Trees
Loading...
Searching...
No Matches
any_types.hpp
1/* Copyright (C) 2022-2025 Davide Faconti - All Rights Reserved
2*
3* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
4* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
5* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7*
8* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
10* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11*/
12
13#pragma once
14
15#include "behaviortree_cpp/utils/safe_any.hpp"
16
17#include <stdexcept>
18#include <string>
19#include <string_view>
20#include <vector>
21
22namespace BT::Scripting
23{
24
25enum class TokenType
26{
27 // Literals
28 Integer,
29 Real,
30 String,
31 Boolean,
32 // Identifier
33 Identifier,
34 // Arithmetic
35 Plus,
36 Minus,
37 Star,
38 Slash,
39 DotDot,
40 // Bitwise
41 Ampersand,
42 Pipe,
43 Caret,
44 Tilde,
45 // Logical
46 AmpAmp,
47 PipePipe,
48 Bang,
49 // Comparison
50 EqualEqual,
51 BangEqual,
52 Less,
53 Greater,
54 LessEqual,
55 GreaterEqual,
56 // Assignment
57 ColonEqual,
58 Equal,
59 PlusEqual,
60 MinusEqual,
61 StarEqual,
62 SlashEqual,
63 // Ternary
64 Question,
65 Colon,
66 // Delimiters
67 LeftParen,
68 RightParen,
69 Semicolon,
70 // Control
71 EndOfInput,
72 Error
73};
74
75/// Lightweight token referencing the source string via string_view.
76/// The source string must outlive the token vector.
77struct Token
78{
79 TokenType type = TokenType::Error;
80 std::string_view text;
81 size_t pos = 0;
82};
83
84std::vector<Token> tokenize(const std::string& source);
85
86} // namespace BT::Scripting
Definition: action_node.h:24
Definition: any_types.hpp:78