UNPKG

ocat-lang

Version:

A programming language for the web design and development

33 lines (32 loc) 816 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getType = getType; exports.getValue = getValue; const utils_1 = require("../lexer/utils"); function getType(val) { if (val === "true" || val === "false") { return "bool"; } else if (!isNaN(Number(val))) { return "int"; } else if (val.startsWith('"') || val.endsWith('"')) { return "string"; } else { return "undefined"; } } function getValue(val, memory) { var _a; if ((0, utils_1.isValue)(val)) { return { value: val, type: getType(val), name: val }; } else { return ((_a = memory.getVar(val)) !== null && _a !== void 0 ? _a : { value: "onotdefined", type: "string", name: val, }); } }