MCPcopy Create free account
hub / github.com/covscript/covscript / create_context

Function create_context

sources/covscript.cpp:398–569  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

396 }
397
398 context_t create_context(const array &args)
399 {
400 cs_impl::init_extensions();
401 context_t context = std::make_shared<context_type>();
402 context->compiler = std::make_shared<compiler_type>(context);
403 context->instance = std::make_shared<instance_type>(context, current_process->stack_size);
404 context->cmd_args = cs::var::make_constant<cs::array>(args);
405 // Init Grammars
406 (*context->compiler)
407 // Expression Grammar
408 .add_method({new token_expr(tree_type<token_base *>()), new token_endline(0)}, new method_expression)
409 // Import Grammar
410 .add_method({new token_action(action_types::import_), new token_expr(tree_type<token_base *>()),
411 new token_endline(0)},
412 new method_import)
413 .add_method({new token_action(action_types::import_), new token_expr(tree_type<token_base *>()),
414 new token_action(action_types::as_), new token_expr(tree_type<token_base *>()),
415 new token_endline(0)},
416 new method_import_as)
417 // Package Grammar
418 .add_method({new token_action(action_types::package_), new token_expr(tree_type<token_base *>()),
419 new token_endline(0)},
420 new method_package)
421 // Involve Grammar
422 .add_method({new token_action(action_types::using_), new token_expr(tree_type<token_base *>()),
423 new token_endline(0)},
424 new method_involve)
425 // Var Grammar
426 .add_method({new token_action(action_types::var_), new token_expr(tree_type<token_base *>()),
427 new token_endline(0)},
428 new method_var)
429 .add_method({new token_action(action_types::link_), new token_expr(tree_type<token_base *>()),
430 new token_endline(0)},
431 new method_link)
432 .add_method({new token_action(action_types::constant_), new token_expr(tree_type<token_base *>()),
433 new token_endline(0)},
434 new method_constant)
435 // End Grammar
436 .add_method({new token_action(action_types::endblock_), new token_endline(0)}, new method_end)
437 // Block Grammar
438 .add_method({new token_action(action_types::block_), new token_endline(0)}, new method_block)
439 // Namespace Grammar
440 .add_method({new token_action(action_types::namespace_), new token_expr(tree_type<token_base *>()),
441 new token_endline(0)},
442 new method_namespace)
443 // If Grammar
444 .add_method({new token_action(action_types::if_), new token_expr(tree_type<token_base *>()),
445 new token_endline(0)},
446 new method_if)
447 // Else Grammar
448 .add_method({new token_action(action_types::else_), new token_endline(0)}, new method_else)
449 // Switch Grammar
450 .add_method({new token_action(action_types::switch_), new token_expr(tree_type<token_base *>()),
451 new token_endline(0)},
452 new method_switch)
453 // Case Grammar
454 .add_method({new token_action(action_types::case_), new token_expr(tree_type<token_base *>()),
455 new token_endline(0)},

Callers 3

covscript_mainFunction · 0.85
covscript_mainFunction · 0.85
bootstrapMethod · 0.85

Calls 4

init_extensionsFunction · 0.85
make_cniFunction · 0.85
make_namespaceFunction · 0.85
numericFunction · 0.50

Tested by

no test coverage detected