2026-07-18 18:48:23 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <Python.h>
|
|
|
|
|
|
|
|
|
|
#include "machine.h"
|
|
|
|
|
|
|
|
|
|
class Eval_python
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
static std::regex statement_delimiter;
|
Klammerset: the @@@klammerset construct, its search path, and const correctness
The @@@klammerset system command formally declares a klammerset — a
named, logically related group of klammer definitions — with an
operative, idempotent declaration (:requires and :files load in order
at the declaration point, relative to the declaring file). A bare
symbol given to ktext -k, kdesc --input, or :requires resolves to
x/x.k on the search path: the document's directory, then
KLAMMERTEXT_KLAMMERSETS, then KLAMMERTEXT_HOME; kdesc --klammerset
lists the available sets. sks/sks.k is the first declared klammerset,
so `-k sks` loads the SKS by name. The engine's lookup classes were
renamed *_set → *_registry to keep the two concepts apart, and the
whole C++ tree now follows standard const-correctness conventions.
tst/ gains klammerset_test.sh (18 cases).
(from dev 64b1abf23e56)
2026-07-30 23:50:07 +02:00
|
|
|
explicit Eval_python(Machine& machine, const Locator& loc);
|
2026-07-18 18:48:23 +02:00
|
|
|
Eval_python(const Eval_python&) = delete;
|
|
|
|
|
Eval_python& operator=(const Eval_python&) = delete;
|
|
|
|
|
~Eval_python();
|
|
|
|
|
void add_module_path(const std::string& path);
|
|
|
|
|
std::vector<std::string> parse_modules(std::string code);
|
Klammerset: the @@@klammerset construct, its search path, and const correctness
The @@@klammerset system command formally declares a klammerset — a
named, logically related group of klammer definitions — with an
operative, idempotent declaration (:requires and :files load in order
at the declaration point, relative to the declaring file). A bare
symbol given to ktext -k, kdesc --input, or :requires resolves to
x/x.k on the search path: the document's directory, then
KLAMMERTEXT_KLAMMERSETS, then KLAMMERTEXT_HOME; kdesc --klammerset
lists the available sets. sks/sks.k is the first declared klammerset,
so `-k sks` loads the SKS by name. The engine's lookup classes were
renamed *_set → *_registry to keep the two concepts apart, and the
whole C++ tree now follows standard const-correctness conventions.
tst/ gains klammerset_test.sh (18 cases).
(from dev 64b1abf23e56)
2026-07-30 23:50:07 +02:00
|
|
|
void import_module(const std::string& module_name, bool verify = true);
|
2026-07-18 18:48:23 +02:00
|
|
|
std::string get_result(PyObject* result_object);
|
Klammerset: the @@@klammerset construct, its search path, and const correctness
The @@@klammerset system command formally declares a klammerset — a
named, logically related group of klammer definitions — with an
operative, idempotent declaration (:requires and :files load in order
at the declaration point, relative to the declaring file). A bare
symbol given to ktext -k, kdesc --input, or :requires resolves to
x/x.k on the search path: the document's directory, then
KLAMMERTEXT_KLAMMERSETS, then KLAMMERTEXT_HOME; kdesc --klammerset
lists the available sets. sks/sks.k is the first declared klammerset,
so `-k sks` loads the SKS by name. The engine's lookup classes were
renamed *_set → *_registry to keep the two concepts apart, and the
whole C++ tree now follows standard const-correctness conventions.
tst/ gains klammerset_test.sh (18 cases).
(from dev 64b1abf23e56)
2026-07-30 23:50:07 +02:00
|
|
|
std::string eval_expression(const std::string& expression, bool import_modules = true);
|
|
|
|
|
std::string eval_statements(const std::string& script);
|
2026-07-18 18:48:23 +02:00
|
|
|
std::string eval(std::string code);
|
|
|
|
|
//std::string eval_katom_list(const katom_iter& begin, const katom_iter& end);
|
|
|
|
|
std::string eval_katom_list(
|
|
|
|
|
std::vector<Katom>& katoms,
|
|
|
|
|
const std::vector<Katom>::iterator& begin, const std::vector<Katom>::iterator& end);
|
|
|
|
|
|
|
|
|
|
Machine m_machine;
|
|
|
|
|
Locator m_loc;
|
|
|
|
|
PyObject* m_globals;
|
|
|
|
|
PyObject* m_locals;
|
|
|
|
|
};
|