TAO: raw taos

A tao like this:

embedded js`: raw [
function meta(input) {
  return input.at('[') || input.at('`') || input.at(']')
function tree(input) {
  if (input.at('[')) { input.next()
    const tree = tao(input.until(']'))
    return ['tree', tree]
function tao(input) {
  const tao = []
  while (true) {
    if (input.done()) return ['tao', tao]
    tao.push(tree(input) || op(input) || note(input))

Contains embedded JavaScript which in turn in its syntax contains square brackets and sometimes the ` symbol. Nonetheless this embedded JavaScript is valid TAO, because all brackets are balanced and there are no ` symbols in conjunction with either ` or [ or ]. These constraints are sufficient to represent any embedded string within TAO, regardless of what other symbol combinations it contains.

Interpretation of a tao as an embedded string like this may be enforced explicitly by using a type annotation, like the raw here.

Such a raw tao could be processed by unparsing with a simple modification on encountering an op symbol `: if it is followed by any of the 3 meta symbols then the unparse will only include the meta symbol. This means that in a raw tao it is only necessary to escape the following:

These cases are very rare indeed, as most brackets in any kind of text are balanced and the ` symbol is among the least frequently occuring and especially in combination with any of the three TAO meta symbols.

In this way, by means reducing probability and sticking to minimalism, we get a powerful syntactical feature “for free”. There is no need for specialized mechanisms such as multiline strings or here documents. The “escape friction” that remains is so negligible that introducing such mechanisms would add more complexity than subtract.