@eagleoutice/flowr
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
50 lines • 1.65 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.normalizeNumber = normalizeNumber;
const convert_values_1 = require("../../../../../convert-values");
const normalize_meta_1 = require("../../normalize-meta");
const type_1 = require("../../../../model/type");
/**
* Normalize the given object as a R number (see {@link number2ts}), supporting booleans (see {@link boolean2ts}),
* and special values.
* This requires you to check the corresponding name beforehand.
*
* @param data - The data used by the parser (see {@link NormalizerData})
* @param obj - The JSON object to extract the meta-information from
*/
function normalizeNumber(data, obj) {
const { location, content } = (0, normalize_meta_1.retrieveMetaStructure)(obj);
const common = {
location,
lexeme: content,
info: {
fullRange: data.currentRange,
additionalTokens: [],
fullLexeme: data.currentLexeme
}
};
/* the special symbol */
if ((0, convert_values_1.isNA)(content)) {
return {
...common,
namespace: undefined,
type: type_1.RType.Symbol,
content
};
}
else if ((0, convert_values_1.isBoolean)(content)) {
return {
...common,
type: type_1.RType.Logical,
content: (0, convert_values_1.boolean2ts)(content)
};
}
else {
return {
...common,
type: type_1.RType.Number,
content: (0, convert_values_1.number2ts)(content)
};
}
}
//# sourceMappingURL=normalize-number.js.map