GameApi 28
Library used by GameApi Builder tool
Loading...
Searching...
No Matches
chaiscript_common.hpp
Go to the documentation of this file.
1// This file is distributed under the BSD License.
2// See "license.txt" for details.
3// Copyright 2009-2012, Jonathan Turner (jonathan@emptycrate.com)
4// Copyright 2009-2017, Jason Turner (jason@emptycrate.com)
5// http://www.chaiscript.com
6
7// This is an open source non-commercial project. Dear PVS-Studio, please check it.
8// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
9
10
11#ifndef CHAISCRIPT_COMMON_HPP_
12#define CHAISCRIPT_COMMON_HPP_
13
14#include <algorithm>
15#include <memory>
16#include <sstream>
17#include <stdexcept>
18#include <string>
19#include <vector>
20
26
27namespace chaiscript {
28struct AST_Node;
29} // namespace chaiscript
30
31namespace chaiscript
32{
34 static bool is_reserved_word(const std::string &name)
35 {
36 static const std::set<std::string> m_reserved_words
37 = {"def", "fun", "while", "for", "if", "else", "&&", "||", ",", "auto",
38 "return", "break", "true", "false", "class", "attr", "var", "global", "GLOBAL", "_",
39 "__LINE__", "__FILE__", "__FUNC__", "__CLASS__"};
40 return m_reserved_words.count(name) > 0;
41 }
42
43 static bool valid_object_name(const std::string &name)
44 {
45 return name.find("::") == std::string::npos && !is_reserved_word(name);
46 }
47
48 static void validate_object_name(const std::string &name)
49 {
52 }
53
54 if (name.find("::") != std::string::npos) {
56 }
57 }
58 };
59
62
63
70 };
71
75
76 namespace
77 {
79 inline const char *ast_node_type_to_string(AST_Node_Type ast_node_type) {
80 static const char * const ast_node_types[] = { "Id", "Fun_Call", "Unused_Return_Fun_Call", "Arg_List", "Equation", "Var_Decl", "Assign_Decl",
81 "Array_Call", "Dot_Access",
82 "Lambda", "Block", "Scopeless_Block", "Def", "While", "If", "For", "Ranged_For", "Inline_Array", "Inline_Map", "Return", "File", "Prefix", "Break", "Continue", "Map_Pair", "Value_Range",
83 "Inline_Range", "Try", "Catch", "Finally", "Method", "Attr_Decl",
84 "Logical_And", "Logical_Or", "Reference", "Switch", "Case", "Default", "Noop", "Class", "Binary", "Arg", "Global_Decl", "Constant", "Compiled"};
85
86 return ast_node_types[static_cast<int>(ast_node_type)];
87 }
88 }
89
92 int line;
93 int column;
94
95 File_Position(int t_file_line, int t_file_column)
96 : line(t_file_line), column(t_file_column) { }
97
98 File_Position() : line(0), column(0) { }
99 };
100
102 Parse_Location(std::string t_fname="", const int t_start_line=0, const int t_start_col=0,
103 const int t_end_line=0, const int t_end_col=0)
104 : start(t_start_line, t_start_col),
105 end(t_end_line, t_end_col),
106 filename(std::make_shared<std::string>(std::move(t_fname)))
107 {
108 }
109
110 Parse_Location(std::shared_ptr<std::string> t_fname, const int t_start_line=0, const int t_start_col=0,
111 const int t_end_line=0, const int t_end_col=0)
112 : start(t_start_line, t_start_col),
113 end(t_end_line, t_end_col),
114 filename(std::move(t_fname))
115 {
116 }
117
118
119
122 std::shared_ptr<std::string> filename;
123 };
124
125
127 typedef std::unique_ptr<AST_Node> AST_NodePtr;
128 typedef std::unique_ptr<const AST_Node> AST_NodePtr_Const;
129
130 struct AST_Node_Trace;
131
132
134 namespace exception
135 {
137 struct load_module_error : std::runtime_error
138 {
139 explicit load_module_error(const std::string &t_reason) noexcept
140 : std::runtime_error(t_reason)
141 {
142 }
143
144 load_module_error(const std::string &t_name, const std::vector<load_module_error> &t_errors)
145 : std::runtime_error(format_error(t_name, t_errors))
146 {
147 }
148
150 ~load_module_error() noexcept override = default;
151
152 static std::string format_error(const std::string &t_name, const std::vector<load_module_error> &t_errors)
153 {
154 std::stringstream ss;
155 ss << "Error loading module '" << t_name << "'\n"
156 << " The following locations were searched:\n";
157
158 for (const auto &err : t_errors) {
159 ss << " " << err.what() << "\n";
160 }
161
162 return ss.str();
163 }
164 };
165
166
168 struct eval_error : std::runtime_error {
169 std::string reason;
171 std::string filename;
172 std::string detail;
173 std::vector<AST_Node_Trace> call_stack;
174
175 eval_error(const std::string &t_why, const File_Position &t_where, const std::string &t_fname,
176 const std::vector<Boxed_Value> &t_parameters, const std::vector<chaiscript::Const_Proxy_Function> &t_functions,
177 bool t_dot_notation,
178 const chaiscript::detail::Dispatch_Engine &t_ss) noexcept :
179 std::runtime_error(format(t_why, t_where, t_fname, t_parameters, t_dot_notation, t_ss)),
180 reason(t_why), start_position(t_where), filename(t_fname), detail(format_detail(t_functions, t_dot_notation, t_ss))
181 {}
182
183 eval_error(const std::string &t_why,
184 const std::vector<Boxed_Value> &t_parameters, const std::vector<chaiscript::Const_Proxy_Function> &t_functions,
185 bool t_dot_notation,
186 const chaiscript::detail::Dispatch_Engine &t_ss) noexcept :
187 std::runtime_error(format(t_why, t_parameters, t_dot_notation, t_ss)),
188 reason(t_why), detail(format_detail(t_functions, t_dot_notation, t_ss))
189 {}
190
191
192 eval_error(const std::string &t_why, const File_Position &t_where, const std::string &t_fname) noexcept :
193 std::runtime_error(format(t_why, t_where, t_fname)),
194 reason(t_why), start_position(t_where), filename(t_fname)
195 {}
196
197 explicit eval_error(const std::string &t_why) noexcept
198 : std::runtime_error("Error: \"" + t_why + "\" "),
199 reason(t_why)
200 {}
201
202 eval_error(const eval_error &) = default;
203
204 std::string pretty_print() const
205 {
206 std::ostringstream ss;
207
208 ss << what();
209 if (!call_stack.empty()) {
210 ss << "during evaluation at (" << fname(call_stack[0]) << " " << startpos(call_stack[0]) << ")\n";
211 ss << '\n' << detail << '\n';
212 ss << " " << fname(call_stack[0]) << " (" << startpos(call_stack[0]) << ") '" << pretty(call_stack[0]) << "'";
213 for (size_t j = 1; j < call_stack.size(); ++j) {
216 {
217 ss << '\n';
218 ss << " from " << fname(call_stack[j]) << " (" << startpos(call_stack[j]) << ") '" << pretty(call_stack[j]) << "'";
219 }
220 }
221 }
222 ss << '\n';
223 return ss.str();
224 }
225
226 ~eval_error() noexcept override = default;
227
228 private:
229
230 template<typename T>
231 static AST_Node_Type id(const T& t)
232 {
233 return t.identifier;
234 }
235
236 template<typename T>
237 static std::string pretty(const T& t)
238 {
239 return t.pretty_print();
240 }
241
242 template<typename T>
243 static const std::string &fname(const T& t)
244 {
245 return t.filename();
246 }
247
248 template<typename T>
249 static std::string startpos(const T& t)
250 {
251 std::ostringstream oss;
252 oss << t.start().line << ", " << t.start().column;
253 return oss.str();
254 }
255
256 static std::string format_why(const std::string &t_why)
257 {
258 return "Error: \"" + t_why + "\"";
259 }
260
261 static std::string format_types(const Const_Proxy_Function &t_func,
262 bool t_dot_notation,
263 const chaiscript::detail::Dispatch_Engine &t_ss)
264 {
265 assert(t_func);
266 int arity = t_func->get_arity();
267 std::vector<Type_Info> types = t_func->get_param_types();
268
269 std::string retval;
270 if (arity == -1)
271 {
272 retval = "(...)";
273 if (t_dot_notation)
274 {
275 retval = "(Object)." + retval;
276 }
277 } else if (types.size() <= 1) {
278 retval = "()";
279 } else {
280 std::stringstream ss;
281 ss << "(";
282
283 std::string paramstr;
284
285 for (size_t index = 1;
286 index != types.size();
287 ++index)
288 {
289 paramstr += (types[index].is_const()?"const ":"");
290 paramstr += t_ss.get_type_name(types[index]);
291
292 if (index == 1 && t_dot_notation)
293 {
294 paramstr += ").(";
295 if (types.size() == 2)
296 {
297 paramstr += ", ";
298 }
299 } else {
300 paramstr += ", ";
301 }
302 }
303
304 ss << paramstr.substr(0, paramstr.size() - 2);
305
306 ss << ")";
307 retval = ss.str();
308 }
309
310
311 std::shared_ptr<const dispatch::Dynamic_Proxy_Function> dynfun
312 = std::dynamic_pointer_cast<const dispatch::Dynamic_Proxy_Function>(t_func);
313
314 if (dynfun && dynfun->has_parse_tree())
315 {
316 Proxy_Function f = dynfun->get_guard();
317
318 if (f)
319 {
320 auto dynfunguard = std::dynamic_pointer_cast<const dispatch::Dynamic_Proxy_Function>(f);
321 if (dynfunguard && dynfunguard->has_parse_tree())
322 {
323 retval += " : " + format_guard(dynfunguard->get_parse_tree());
324 }
325 }
326
327 retval += "\n Defined at " + format_location(dynfun->get_parse_tree());
328 }
329
330 return retval;
331 }
332
333 template<typename T>
334 static std::string format_guard(const T &t)
335 {
336 return t.pretty_print();
337 }
338
339 template<typename T>
340 static std::string format_location(const T &t)
341 {
342 std::ostringstream oss;
343 oss << "(" << t.filename() << " " << t.start().line << ", " << t.start().column << ")";
344 return oss.str();
345 }
346
347 static std::string format_detail(const std::vector<chaiscript::Const_Proxy_Function> &t_functions,
348 bool t_dot_notation,
349 const chaiscript::detail::Dispatch_Engine &t_ss)
350 {
351 std::stringstream ss;
352 if (t_functions.size() == 1)
353 {
354 assert(t_functions[0]);
355 ss << " Expected: " << format_types(t_functions[0], t_dot_notation, t_ss) << '\n';
356 } else {
357 ss << " " << t_functions.size() << " overloads available:\n";
358
359 for (const auto & t_function : t_functions)
360 {
361 ss << " " << format_types((t_function), t_dot_notation, t_ss) << '\n';
362 }
363
364 }
365
366 return ss.str();
367
368 }
369
370 static std::string format_parameters(const std::vector<Boxed_Value> &t_parameters,
371 bool t_dot_notation,
372 const chaiscript::detail::Dispatch_Engine &t_ss)
373 {
374 std::stringstream ss;
375 ss << "(";
376
377 if (!t_parameters.empty())
378 {
379 std::string paramstr;
380
381 for (auto itr = t_parameters.begin();
382 itr != t_parameters.end();
383 ++itr)
384 {
385 paramstr += (itr->is_const()?"const ":"");
386 paramstr += t_ss.type_name(*itr);
387
388 if (itr == t_parameters.begin() && t_dot_notation)
389 {
390 paramstr += ").(";
391 if (t_parameters.size() == 1)
392 {
393 paramstr += ", ";
394 }
395 } else {
396 paramstr += ", ";
397 }
398 }
399
400 ss << paramstr.substr(0, paramstr.size() - 2);
401 }
402 ss << ")";
403
404 return ss.str();
405 }
406
407 static std::string format_filename(const std::string &t_fname)
408 {
409 std::stringstream ss;
410
411 if (t_fname != "__EVAL__")
412 {
413 ss << "in '" << t_fname << "' ";
414 } else {
415 ss << "during evaluation ";
416 }
417
418 return ss.str();
419 }
420
421 static std::string format_location(const File_Position &t_where)
422 {
423 std::stringstream ss;
424 ss << "at (" << t_where.line << ", " << t_where.column << ")";
425 return ss.str();
426 }
427
428 static std::string format(const std::string &t_why, const File_Position &t_where, const std::string &t_fname,
429 const std::vector<Boxed_Value> &t_parameters, bool t_dot_notation, const chaiscript::detail::Dispatch_Engine &t_ss)
430 {
431 std::stringstream ss;
432
433 ss << format_why(t_why);
434 ss << " ";
435
436 ss << "With parameters: " << format_parameters(t_parameters, t_dot_notation, t_ss);
437 ss << " ";
438
439 ss << format_filename(t_fname);
440 ss << " ";
441
442 ss << format_location(t_where);
443
444 return ss.str();
445 }
446
447 static std::string format(const std::string &t_why,
448 const std::vector<Boxed_Value> &t_parameters,
449 bool t_dot_notation,
450 const chaiscript::detail::Dispatch_Engine &t_ss)
451 {
452 std::stringstream ss;
453
454 ss << format_why(t_why);
455 ss << " ";
456
457 ss << "With parameters: " << format_parameters(t_parameters, t_dot_notation, t_ss);
458 ss << " ";
459
460 return ss.str();
461 }
462
463 static std::string format(const std::string &t_why, const File_Position &t_where, const std::string &t_fname)
464 {
465 std::stringstream ss;
466
467 ss << format_why(t_why);
468 ss << " ";
469
470 ss << format_filename(t_fname);
471 ss << " ";
472
473 ss << format_location(t_where);
474
475 return ss.str();
476 }
477 };
478
479
481 struct file_not_found_error : std::runtime_error {
482 explicit file_not_found_error(const std::string &t_filename) noexcept
483 : std::runtime_error("File Not Found: " + t_filename),
484 filename(t_filename)
485 { }
486
488 ~file_not_found_error() noexcept override = default;
489
490 std::string filename;
491 };
492
493 }
494
495
497 struct AST_Node {
498 public:
500 const std::string text;
502
503 const std::string &filename() const {
504 return *location.filename;
505 }
506
507 const File_Position &start() const {
508 return location.start;
509 }
510
511 const File_Position &end() const {
512 return location.end;
513 }
514
515 std::string pretty_print() const
516 {
517 std::ostringstream oss;
518
519 oss << text;
520
521 for (auto & elem : get_children()) {
522 oss << elem.get().pretty_print() << ' ';
523 }
524
525 return oss.str();
526 }
527
528 virtual std::vector<std::reference_wrapper<AST_Node>> get_children() const = 0;
530
531
533 std::string to_string(const std::string &t_prepend = "") const {
534 std::ostringstream oss;
535
536 oss << t_prepend << "(" << ast_node_type_to_string(this->identifier) << ") "
537 << this->text << " : " << this->location.start.line << ", " << this->location.start.column << '\n';
538
539 for (auto & elem : get_children()) {
540 oss << elem.get().to_string(t_prepend + " ");
541 }
542 return oss.str();
543 }
544
545
547 try {
548 return t_ss->boxed_cast<bool>(t_bv);
549 }
550 catch (const exception::bad_boxed_cast &) {
551 throw exception::eval_error("Condition not boolean");
552 }
553 }
554
555
556 virtual ~AST_Node() = default;
557 AST_Node(AST_Node &&) = default;
559 AST_Node(const AST_Node &) = delete;
560 AST_Node& operator=(const AST_Node &) = delete;
561
562
563 protected:
564 AST_Node(std::string t_ast_node_text, AST_Node_Type t_id, Parse_Location t_loc)
565 : identifier(t_id), text(std::move(t_ast_node_text)),
566 location(std::move(t_loc))
567 {
568 }
569
570
571 };
572
574 {
576 const std::string text;
578
579 const std::string &filename() const {
580 return *location.filename;
581 }
582
583 const File_Position &start() const {
584 return location.start;
585 }
586
587 const File_Position &end() const {
588 return location.end;
589 }
590
591 std::string pretty_print() const
592 {
593 std::ostringstream oss;
594
595 oss << text;
596
597 for (const auto & elem : children) {
598 oss << elem.pretty_print() << ' ';
599 }
600
601 return oss.str();
602 }
603
604 std::vector<AST_Node_Trace> get_children(const AST_Node &node)
605 {
606 const auto node_children = node.get_children();
607 return std::vector<AST_Node_Trace>(node_children.begin(), node_children.end());
608 }
609
611 : identifier(node.identifier), text(node.text),
613 {
614 }
615
616
617 std::vector<AST_Node_Trace> children;
618
619 };
620
621 namespace parser {
623 {
624 public:
625 virtual AST_NodePtr parse(const std::string &t_input, const std::string &t_fname) = 0;
626 virtual void debug_print(const AST_Node &t, std::string prepend = "") const = 0;
627 virtual void *get_tracer_ptr() = 0;
628 virtual ~ChaiScript_Parser_Base() = default;
633
634 template<typename T>
636 {
637 // to do type check this somehow?
638 return *static_cast<T*>(get_tracer_ptr());
639 }
640
641 protected:
643 };
644 }
645
646 namespace eval
647 {
648 namespace detail
649 {
654
655
657 struct Break_Loop {
658 Break_Loop() = default;
659 };
660
661
664 Continue_Loop() = default;
665 };
666
667
670 {
675
677 : m_ds(t_ds)
678 {
679 m_ds->new_scope(m_ds.stack_holder());
680 }
681
683 {
684 m_ds->pop_scope(m_ds.stack_holder());
685 }
686
687
688 private:
690 };
691
694 {
699
701 : m_ds(t_ds)
702 {
703 m_ds->new_function_call(m_ds.stack_holder(), m_ds.conversion_saves());
704 }
705
707 {
708 m_ds->pop_function_call(m_ds.stack_holder(), m_ds.conversion_saves());
709 }
710
711 void save_params(const std::vector<Boxed_Value> &t_params)
712 {
713 m_ds->save_function_params(t_params);
714 }
715
716 void save_params(std::initializer_list<Boxed_Value> t_params)
717 {
718 m_ds->save_function_params(t_params);
719 }
720
721
722 private:
724 };
725
728 {
733
735 : m_ds(t_ds)
736 {
737 m_ds->new_stack(m_ds.stack_holder());
738 }
739
741 {
742 m_ds->pop_stack(m_ds.stack_holder());
743 }
744
745
746 private:
748 };
749 }
750 }
751}
752
753#endif /* _CHAISCRIPT_COMMON_HPP */
754
Definition GameApi_pl.cc:23060
Definition Math.hh:178
Definition Web.hh:23
A wrapper for holding any valid C++ type. All types in ChaiScript are Boxed_Value objects.
Definition boxed_value.hpp:28
Definition dispatchkit.hpp:438
decltype(auto) boxed_cast(const Boxed_Value &bv) const
casts an object while applying any Dynamic_Conversion available
Definition dispatchkit.hpp:462
std::string get_type_name(const Type_Info &ti) const
Definition dispatchkit.hpp:743
std::string type_name(const Boxed_Value &obj) const
Definition dispatchkit.hpp:1180
Definition dispatchkit.hpp:1513
Thrown in the event that a Boxed_Value cannot be cast to the desired type.
Definition bad_boxed_cast.hpp:34
Exception thrown in the case that an object name is invalid because it contains illegal characters.
Definition dispatchkit.hpp:87
Exception thrown in the case that an object name is invalid because it is a reserved word.
Definition dispatchkit.hpp:65
ChaiScript_Parser_Base(ChaiScript_Parser_Base &&)=default
virtual AST_NodePtr parse(const std::string &t_input, const std::string &t_fname)=0
ChaiScript_Parser_Base & operator=(const ChaiScript_Parser_Base &&)=delete
ChaiScript_Parser_Base(const ChaiScript_Parser_Base &)=default
ChaiScript_Parser_Base & operator=(ChaiScript_Parser_Base &&)=delete
T & get_tracer()
Definition chaiscript_common.hpp:635
virtual void debug_print(const AST_Node &t, std::string prepend="") const =0
pretty($str)
Definition mesh_api.php:105
iVBORw0KGgoAAAANSUhEUgAAANcAAAB5CAMAAACdtUQZAAAA51BMVEX</div ></div >< div style="padding: 0px 0px; width: 1324px;">< div style="height: 400px; width: 1324px;"></div >< div itemscope itemtype="https: </div><div itemscope itemtype="https:</div >< div itemscope itemtype="https: </div></div><p><div style="padding:0px 0px;width:1324px;"><div></div><div itemscope itemtype="https:< ul >< li >< b > Application name
8AkrcAgqgAs9wqQ0ey2tkAo8gAuuQfeI4hPUH09fXHy8z4+fng4uNKXF/Lz9BzfoAcgpkQMTUAKjAbOT4Qr9AXhJ8Rl7ktMCwTosA...
Definition meshpage.php:1610
instead of< li > Displaying models works via URL t expect full length movie as the output of this process< li > Different animation models are very limited basically just translate rotate</ul >< h2 > What to do if your hosting location has no php</h2 >< ul >< li > comment out or remove display php lines at the beginning< li > you will lose threads too< li > every zip file distributed by meshpage org has one of those display php files with this issue</ul >< h2 > What should I do to serve the files via http</h2 > I get some random triangles that do not belong to the model</h2 > The engine works correctly The obj file supports quads and polygons But some external tools that create obj files insert random polygons to the file to discourage rendering of polygons We consider polygon rendering is important and our engine should support it by default If you have we have disable_polygons() feature in the engine to get rid of the trash. But real solution is to change the tool you use to create the .obj file/check the .obj file that it doesn 't contain random(invisible) polygons that do not render in competing 3d engines. Our engine does not have the performance problems normally associated with polygons given that triangle quad polygon type change does not cause additional draw commands to the opengl rendering< p > GLTF standard organisation made significant mistake when specifying GLTF file format
Definition meshpage.php:1092
Definition catch.hpp:90
Definition chaiscript_common.hpp:649
Classes and functions that are part of the runtime eval system.
Definition chaiscript_common.hpp:647
Classes which may be thrown during error cases when ChaiScript is executing.
Definition bad_boxed_cast.hpp:27
Classes and functions used during the parsing process.
Definition dispatchkit.hpp:44
Namespace chaiscript contains every API call that the average user will be concerned with.
std::shared_ptr< dispatch::Proxy_Function_Base > Proxy_Function
Common typedef used for passing of any registered function in ChaiScript.
Definition proxy_functions.hpp:317
std::shared_ptr< const dispatch::Proxy_Function_Base > Const_Proxy_Function
Const version of Proxy_Function. Points to a const Proxy_Function. This is how most registered functi...
Definition proxy_functions.hpp:321
Operator_Precidence
Definition chaiscript_common.hpp:72
@ Multiplication
Definition chaiscript_common.hpp:74
@ Ternary_Cond
Definition chaiscript_common.hpp:72
@ Addition
Definition chaiscript_common.hpp:74
@ Shift
Definition chaiscript_common.hpp:74
@ Equality
Definition chaiscript_common.hpp:74
@ Bitwise_Xor
Definition chaiscript_common.hpp:73
@ Bitwise_Or
Definition chaiscript_common.hpp:73
@ Bitwise_And
Definition chaiscript_common.hpp:73
@ Comparison
Definition chaiscript_common.hpp:74
std::unique_ptr< const AST_Node > AST_NodePtr_Const
Definition chaiscript_common.hpp:128
std::shared_ptr< B > make_shared(Arg &&... arg)
Definition chaiscript_defines.hpp:87
AST_Node_Type
Types of AST nodes available to the parser and eval.
Definition chaiscript_common.hpp:65
@ Lambda
Definition chaiscript_common.hpp:67
@ Case
Definition chaiscript_common.hpp:69
@ File
Definition chaiscript_common.hpp:67
@ Assign_Decl
Definition chaiscript_common.hpp:65
@ Array_Call
Definition chaiscript_common.hpp:66
@ Dot_Access
Definition chaiscript_common.hpp:66
@ Map_Pair
Definition chaiscript_common.hpp:67
@ Noop
Definition chaiscript_common.hpp:69
@ Var_Decl
Definition chaiscript_common.hpp:65
@ For
Definition chaiscript_common.hpp:67
@ While
Definition chaiscript_common.hpp:67
@ Id
Definition chaiscript_common.hpp:65
@ Scopeless_Block
Definition chaiscript_common.hpp:67
@ Global_Decl
Definition chaiscript_common.hpp:69
@ Method
Definition chaiscript_common.hpp:68
@ Compiled
Definition chaiscript_common.hpp:69
@ Logical_And
Definition chaiscript_common.hpp:69
@ Finally
Definition chaiscript_common.hpp:68
@ Arg
Definition chaiscript_common.hpp:69
@ Reference
Definition chaiscript_common.hpp:69
@ Value_Range
Definition chaiscript_common.hpp:67
@ Binary
Definition chaiscript_common.hpp:69
@ Unused_Return_Fun_Call
Definition chaiscript_common.hpp:65
@ Prefix
Definition chaiscript_common.hpp:67
@ Inline_Array
Definition chaiscript_common.hpp:67
@ If
Definition chaiscript_common.hpp:67
@ Default
Definition chaiscript_common.hpp:69
@ Arg_List
Definition chaiscript_common.hpp:65
@ Logical_Or
Definition chaiscript_common.hpp:69
@ Ranged_For
Definition chaiscript_common.hpp:67
@ Return
Definition chaiscript_common.hpp:67
@ Continue
Definition chaiscript_common.hpp:67
@ Switch
Definition chaiscript_common.hpp:69
@ Inline_Map
Definition chaiscript_common.hpp:67
@ Fun_Call
Definition chaiscript_common.hpp:65
@ Constant
Definition chaiscript_common.hpp:69
@ Def
Definition chaiscript_common.hpp:67
@ Block
Definition chaiscript_common.hpp:67
@ Break
Definition chaiscript_common.hpp:67
@ Try
Definition chaiscript_common.hpp:68
@ Attr_Decl
Definition chaiscript_common.hpp:68
@ Inline_Range
Definition chaiscript_common.hpp:68
std::shared_ptr< Module > ModulePtr
Convenience typedef for Module objects to be added to the ChaiScript runtime.
Definition dispatchkit.hpp:263
std::unique_ptr< AST_Node > AST_NodePtr
Typedef for pointers to AST_Node objects. Used in building of the AST_Node tree.
Definition proxy_functions.hpp:44
ModulePtr(* Create_Module_Func)()
Signature of module entry point that all binary loadable modules must implement.
Definition chaiscript_common.hpp:61
STL namespace.
double f(const std::string &, double, bool) noexcept
Definition profile_cpp_calls_2.cpp:4
Definition parser.cc:9
Definition GameApi.h:42
Definition chaiscript_common.hpp:574
std::string pretty_print() const
Definition chaiscript_common.hpp:591
const File_Position & end() const
Definition chaiscript_common.hpp:587
Parse_Location location
Definition chaiscript_common.hpp:577
AST_Node_Trace(const AST_Node &node)
Definition chaiscript_common.hpp:610
const File_Position & start() const
Definition chaiscript_common.hpp:583
const AST_Node_Type identifier
Definition chaiscript_common.hpp:575
const std::string & filename() const
Definition chaiscript_common.hpp:579
std::vector< AST_Node_Trace > get_children(const AST_Node &node)
Definition chaiscript_common.hpp:604
std::vector< AST_Node_Trace > children
Definition chaiscript_common.hpp:617
const std::string text
Definition chaiscript_common.hpp:576
Struct that doubles as both a parser ast_node and an AST node.
Definition chaiscript_common.hpp:497
virtual ~AST_Node()=default
AST_Node & operator=(AST_Node &&)=default
AST_Node(AST_Node &&)=default
AST_Node(const AST_Node &)=delete
const std::string text
Definition chaiscript_common.hpp:500
AST_Node & operator=(const AST_Node &)=delete
AST_Node(std::string t_ast_node_text, AST_Node_Type t_id, Parse_Location t_loc)
Definition chaiscript_common.hpp:564
virtual std::vector< std::reference_wrapper< AST_Node > > get_children() const =0
const std::string & filename() const
Definition chaiscript_common.hpp:503
const AST_Node_Type identifier
Definition chaiscript_common.hpp:499
const File_Position & start() const
Definition chaiscript_common.hpp:507
const File_Position & end() const
Definition chaiscript_common.hpp:511
Parse_Location location
Definition chaiscript_common.hpp:501
std::string pretty_print() const
Definition chaiscript_common.hpp:515
std::string to_string(const std::string &t_prepend="") const
Prints the contents of an AST node, including its children, recursively.
Definition chaiscript_common.hpp:533
virtual Boxed_Value eval(const chaiscript::detail::Dispatch_State &t_e) const =0
static bool get_bool_condition(const Boxed_Value &t_bv, const chaiscript::detail::Dispatch_State &t_ss)
Definition chaiscript_common.hpp:546
Convenience type for file positions.
Definition chaiscript_common.hpp:91
int line
Definition chaiscript_common.hpp:92
int column
Definition chaiscript_common.hpp:93
File_Position(int t_file_line, int t_file_column)
Definition chaiscript_common.hpp:95
File_Position()
Definition chaiscript_common.hpp:98
Definition chaiscript_common.hpp:33
static void validate_object_name(const std::string &name)
Definition chaiscript_common.hpp:48
static bool valid_object_name(const std::string &name)
Definition chaiscript_common.hpp:43
static bool is_reserved_word(const std::string &name)
Definition chaiscript_common.hpp:34
Definition chaiscript_common.hpp:101
File_Position start
Definition chaiscript_common.hpp:120
Parse_Location(std::string t_fname="", const int t_start_line=0, const int t_start_col=0, const int t_end_line=0, const int t_end_col=0)
Definition chaiscript_common.hpp:102
std::shared_ptr< std::string > filename
Definition chaiscript_common.hpp:122
File_Position end
Definition chaiscript_common.hpp:121
Parse_Location(std::shared_ptr< std::string > t_fname, const int t_start_line=0, const int t_start_col=0, const int t_end_line=0, const int t_end_col=0)
Definition chaiscript_common.hpp:110
Function_Push_Pop(const chaiscript::detail::Dispatch_State &t_ds)
Definition chaiscript_common.hpp:700
Function_Push_Pop & operator=(const Function_Push_Pop &)=delete
void save_params(const std::vector< Boxed_Value > &t_params)
Definition chaiscript_common.hpp:711
Function_Push_Pop(Function_Push_Pop &&)=default
Function_Push_Pop & operator=(Function_Push_Pop &&)=default
~Function_Push_Pop()
Definition chaiscript_common.hpp:706
Function_Push_Pop(const Function_Push_Pop &)=delete
void save_params(std::initializer_list< Boxed_Value > t_params)
Definition chaiscript_common.hpp:716
Special type for returned values.
Definition chaiscript_common.hpp:651
Boxed_Value retval
Definition chaiscript_common.hpp:652
Scope_Push_Pop & operator=(const Scope_Push_Pop &)=delete
Scope_Push_Pop(const chaiscript::detail::Dispatch_State &t_ds)
Definition chaiscript_common.hpp:676
Scope_Push_Pop(Scope_Push_Pop &&)=default
Scope_Push_Pop(const Scope_Push_Pop &)=delete
~Scope_Push_Pop()
Definition chaiscript_common.hpp:682
Scope_Push_Pop & operator=(Scope_Push_Pop &&)=default
Stack_Push_Pop & operator=(const Stack_Push_Pop &)=delete
Stack_Push_Pop(const chaiscript::detail::Dispatch_State &t_ds)
Definition chaiscript_common.hpp:734
Stack_Push_Pop(const Stack_Push_Pop &)=delete
Stack_Push_Pop(Stack_Push_Pop &&)=default
~Stack_Push_Pop()
Definition chaiscript_common.hpp:740
Stack_Push_Pop & operator=(Stack_Push_Pop &&)=default
Errors generated during parsing or evaluation.
Definition chaiscript_common.hpp:168
std::string detail
Definition chaiscript_common.hpp:172
eval_error(const eval_error &)=default
eval_error(const std::string &t_why) noexcept
Definition chaiscript_common.hpp:197
std::string filename
Definition chaiscript_common.hpp:171
~eval_error() noexcept override=default
std::string reason
Definition chaiscript_common.hpp:169
eval_error(const std::string &t_why, const std::vector< Boxed_Value > &t_parameters, const std::vector< chaiscript::Const_Proxy_Function > &t_functions, bool t_dot_notation, const chaiscript::detail::Dispatch_Engine &t_ss) noexcept
Definition chaiscript_common.hpp:183
eval_error(const std::string &t_why, const File_Position &t_where, const std::string &t_fname, const std::vector< Boxed_Value > &t_parameters, const std::vector< chaiscript::Const_Proxy_Function > &t_functions, bool t_dot_notation, const chaiscript::detail::Dispatch_Engine &t_ss) noexcept
Definition chaiscript_common.hpp:175
File_Position start_position
Definition chaiscript_common.hpp:170
std::vector< AST_Node_Trace > call_stack
Definition chaiscript_common.hpp:173
eval_error(const std::string &t_why, const File_Position &t_where, const std::string &t_fname) noexcept
Definition chaiscript_common.hpp:192
std::string pretty_print() const
Definition chaiscript_common.hpp:204
file_not_found_error(const file_not_found_error &)=default
~file_not_found_error() noexcept override=default
std::string filename
Definition chaiscript_common.hpp:490
file_not_found_error(const std::string &t_filename) noexcept
Definition chaiscript_common.hpp:482
load_module_error(const std::string &t_reason) noexcept
Definition chaiscript_common.hpp:139
static std::string format_error(const std::string &t_name, const std::vector< load_module_error > &t_errors)
Definition chaiscript_common.hpp:152
~load_module_error() noexcept override=default
load_module_error(const std::string &t_name, const std::vector< load_module_error > &t_errors)
Definition chaiscript_common.hpp:144
load_module_error(const load_module_error &)=default