'How convert an atom to a term in Tau Prolog

How would one go about it and extends Tau Prologs core.js
by a new builtin term_atom/2. It would work as follows:

?- term_atom(X, '2 + foo'), write_canonical(X), nl.
+(2, foo)

I find that Tau Prolog has everything to make such a
builtin, since the main exported object pl has:

    // PROLOG
    var pl = {
        // Parser
        parser: {
            tokenizer: Tokenizer,
            expression: parseExpr
        },

But how put all pieces together to make a new built-in.
Maybe somebody did this already and would like to share?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source