Skip to content

Instantly share code, notes, and snippets.

@VimalKumarS
Created October 13, 2014 06:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VimalKumarS/87edbc6a3db3c37dcf34 to your computer and use it in GitHub Desktop.
Save VimalKumarS/87edbc6a3db3c37dcf34 to your computer and use it in GitHub Desktop.
Implemeted syntax parameter simillar to Scheme programming language, in Sweet.js macro.
Eg:
macro aif {
case {
$aif_name
($cond ...) {$tru ...} else { $els ... }
} => {
SyntaxParameter(it, $cond ... , aif ,
return #
{
(function () {
if ($cond ...) {
$tru ...
} else {
$els ...
}
})
})
}
}
== SyntaxParameter(<parameter variable>,<Assigned expression in macro>,<Scope or context>,<apply to function>)
File Modified
In parser.js, parse through the syntax and create a syntaxparam tree object that store the syntax param, corresponding value and store the scope of the macro.
In pattern.js- modified trascribe function
modifeid debug.js
added 3 test cases test1.js,test2.js,test3.js.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment