Skip to content

Instantly share code, notes, and snippets.

@andreypopp
Forked from wilmoore/qw.sweet.js
Last active July 27, 2016 21:01
Show Gist options
  • Save andreypopp/8811790 to your computer and use it in GitHub Desktop.
Save andreypopp/8811790 to your computer and use it in GitHub Desktop.
macro makeString {
case { _ $tok } => {
return [makeValue(#{$tok}[0].token.value, #{here})]
}
}
macro qw {
rule { ($delimited ...) } => { [$(makeString $delimited) (,) ...] }
}
qw(space separated words) // ["space", "separated", "words"]
// http://sweetjs.org/browser/editor.html#macro%20makeString%20%7B%0A%20%20case%20%7B%20_%20$tok%20%7D%20=%3E%20%7B%0A%20%20%09return%20%5BmakeValue(#%7B$tok%7D%5B0%5D.token.value,%20#%7Bhere%7D)%5D%0A%20%20%7D%0A%7D%0Amacro%20qw%20%7B%0A%20%20rule%20%7B%20($delimited%20...)%20%7D%20=%3E%20%7B%20%5B$(makeString%20$delimited)%20(,)%20...%5D%20%7D%0A%7D%0A%0Aqw(space%20separated%20words)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment