Skip to content

Instantly share code, notes, and snippets.

@SimonDanisch
Created November 15, 2014 21:22
Show Gist options
  • Save SimonDanisch/e493bc765b013b2d3bbd to your computer and use it in GitHub Desktop.
Save SimonDanisch/e493bc765b013b2d3bbd to your computer and use it in GitHub Desktop.
macro DSL(name, text)
tokens = dsltokenizer(DSLTokens{name}(), text)::DSLTokens{name}
dslast = generate_ast(tokens)::AST{name}
return dsl(dslast)::AST{:Julia}
end
#Overwrite any of these stages, to implement your own DSL
dsltokenizer(::DSLTokens, text) = ...
generate_ast(text::DSLTokens) = ...
dsl(ast::AST) = ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment