Skip to content
Snippets Groups Projects
  • Ben Cumming's avatar
    Add granule cell mechanisms (#421) · a80df6fa
    Ben Cumming authored and Sam Yates's avatar Sam Yates committed
    * Add three new mechanisms: `nax.mod`, `kdrmt.mod` and `kamt.mod`.
    * Add new built-in math operators to `modcc`: `min`, `max`, `abs` and `exprelr`. `exprelr` is defined as the reciprocal of the 'exprel' function, exprel(x)=x/(exp(x)-1), exprel(1)=1. This function occurs frequently in HH-style mechanisms, and having a built-in operator avoids the ad hoc `vtrap` functions found in NMODL files in the wild.
    * Split Arbor SIMD intrinsics support into AVX2- and AVX512-specific files.
    * Add unit tests for new maths operators for C++, SIMD and CUDA implementations.
    a80df6fa
token.cpp 5.36 KiB
#include <mutex>

#include "token.hpp"

// lookup table used for checking if an identifier matches a keyword
std::unordered_map<std::string, tok> keyword_map;

// for stringifying a token type
std::map<tok, std::string> token_map;

std::mutex mutex;

struct Keyword {
    const char *name;
    tok type;
};

struct TokenString {
    const char *name;
    tok token;
};

static Keyword keywords[] = {
    {"TITLE",       tok::title},
    {"NEURON",      tok::neuron},
    {"UNITS",       tok::units},
    {"PARAMETER",   tok::parameter},
    {"ASSIGNED",    tok::assigned},
    {"STATE",       tok::state},
    {"BREAKPOINT",  tok::breakpoint},
    {"DERIVATIVE",  tok::derivative},
    {"KINETIC",     tok::kinetic},
    {"PROCEDURE",   tok::procedure},
    {"FUNCTION",    tok::function},
    {"INITIAL",     tok::initial},
    {"NET_RECEIVE", tok::net_receive},
    {"UNITSOFF",    tok::unitsoff},
    {"UNITSON",     tok::unitson},
    {"SUFFIX",      tok::suffix},
    {"NONSPECIFIC_CURRENT", tok::nonspecific_current},
    {"USEION",      tok::useion},
    {"READ",        tok::read},
    {"WRITE",       tok::write},
    {"RANGE",       tok::range},
    {"LOCAL",       tok::local},
    {"CONSERVE",    tok::conserve},
    {"SOLVE",       tok::solve},
    {"THREADSAFE",  tok::threadsafe},
    {"GLOBAL",      tok::global},
    {"POINT_PROCESS", tok::point_process},
    {"METHOD",      tok::method},
    {"if",          tok::if_stmt},
    {"else",        tok::else_stmt},
    {"cnexp",       tok::cnexp},
    {"sparse",      tok::sparse},
    {"min",         tok::min},
    {"max",         tok::max},
    {"exp",         tok::exp},
    {"sin",         tok::sin},
    {"cos",         tok::cos},
    {"log",         tok::log},
    {"abs",         tok::abs},
    {"exprelr",     tok::exprelr},
    {"CONDUCTANCE", tok::conductance},
    {nullptr,       tok::reserved},
};

static TokenString token_strings[] = {
    {"=",           tok::eq},
    {"+",           tok::plus},