nk 1.0.0
C++ Numerical Computing Runtime
Loading...
Searching...
No Matches
lang.hpp
Go to the documentation of this file.
1// src/builtin/include/nk/builtin/lang.hpp
2//
3// Pure C++ Language keywords, variable name validation, environment, and evaluation.
4#pragma once
5
6#include <memory_resource>
7#include <string>
8#include <vector>
9#include <nk/value/value.hpp>
10#include <nk/value/span.hpp>
11
12namespace nk::builtin {
13
16
17
24
25#include <nk/fs/branding.hpp>
26
27// ── Environment Variables ───────────────────────────────────────────────────
28
38void setenv(const std::string &name, const std::string &value = "");
39
45std::string getenv(const std::string &name);
46
53Value getenv(const Value &name, std::pmr::memory_resource *mr = nullptr);
54
55// ── Keyword & Identifier Inspection ─────────────────────────────────────────
56
66bool iskeyword(const std::string &name);
67
72const std::vector<std::string> &keywords();
73
83Value iskeyword(Span<const Value> args, std::pmr::memory_resource *mr = nullptr);
84
93bool isvarname(const std::string &name);
94
104Value isvarname(const Value &name, std::pmr::memory_resource *mr = nullptr);
105
112Value isvarname(Span<const Value> args, std::pmr::memory_resource *mr = nullptr);
113
114
116} // namespace nk::builtin
Core MATLAB-compatible multidimensional array and scalar value type.
Definition value.hpp:61
std::string getenv(const std::string &name)
Reads an operating system environment variable as a C++ string (getenv(name)).
const std::vector< std::string > & keywords()
Lists all reserved MATLAB keywords as a C++ vector.
bool isvarname(const std::string &name)
Tests whether a string is a valid MATLAB variable name (isvarname(s)).
void setenv(const std::string &name, const std::string &value="")
Sets or clears an operating system environment variable (setenv(name, value)).
bool iskeyword(const std::string &name)
Tests whether a string is a reserved MATLAB language keyword (iskeyword(s)).