== matchertext [[toc:]] == Description ''matchertext'' is a "syntactic discipline" that allows for cross-language embedding of source code. It was invented by Bryan Ford (who also invented parsing expression grammars and packrat parsing). To learn more, see Ford's [[https://bford.info/pub/lang/matchertext/|introductory blog post]], and his [[https://arxiv.org/abs/2212.14129|more substantial paper]]. Briefly (quote from the blog post), The pragmatic essence of the matchertext idea is simple. First, we define six particular ASCII characters as matchers: namely the open and close parentheses (), the square brackets [], and the curly braces {}. We call these characters matchers because their traditional, already-ubiquitous purpose is to be used in matching pairs to surround and delimit other text. Now we define matchertext as any plain text string conforming to one additional rule or “syntactic discipline”: namely that matchers must match, throughout any matchertext string, without exception. Nesting is allowed, but must use corresponding matchers. For example, the string ‘([{foo}])’ is valid matchertext, but strings like ‘(foo’, ‘bar}’, or ‘(]’ are not matchertext. The matchertext egg extends the Scheme language to be able to host matchertext in string literals. == Syntax #m{MATCHERTEXT} This is a string literal, where {{MATCHERTEXT}} is valid matchertext; no need to escape any characters as long as matchers match. == Examples To run the examples, don't forget to (import matchertext) === Simple usage (string=? "hello, world" #m{hello, world}) ; #t (string=? "#[{(##)}]\\\\(\\)[]#[{\"}]" #m{#[{(##)}]\\(\)[]#[{"}]}) ; #t Let's try to print the code of the above example. (display #m{(string=? "#[{(##)}]\\\\(\\)[]#[{\"}]" #m{#[{(##)}]\\(\)[]#[{"}]}) ; #t}) == Author [[/users/hernan-ibarra-mejia|Hernán Ibarra Mejia]] == Repository Development happens in [[https://git.sr.ht/~nagbu/matchertext|SourceHut]]. == Requirements None (but testing requires the [[test|test egg]]). == Version history ; 1.0 : Initial release. == License [[https://git.sr.ht/~nagbu/matchertext/blob/main/COPYING|GPLv3]].