codelike
Codelike is a utility for creating code-like obects in javascript. For example:
; const codelike = 'Action' ;const site = codelikebuilder; const action = site
This looks like ordinary code but the resulting action
object does not actually do anything. The structure of the statement is simply stored away in a format we can use for our own purposes. The 'codelike' object can be used to convert the structure into a string, so:
codelike
will return a string that looks very like the original statement used to create action. So far, so useless. To really use codelike we need to create a formatter object.
{ thisout=""; } { thisout += name; } { return thisout; } { first; thisout+=';' then; } { thisout+="if("; condition; thisout+=")" thisout+="then"; action; } { first; thisout+=`\${name}`; } { accessor; thisout+=':'; thisout+=`\${name}(
This formatter object will output the code in an entirely different syntax. To use your own formatters, simply do:
const codelike = 'MyAction' myOwnStringify ;
then codelike.myOwnStringify(action) will return a formatted string (or any other type of object) to your own requirements as formatted by myOwnStringify.