Nim does support your original example, e.g.
    
    
    macro mkParser*(name: untyped, args: untyped): untyped =
      # process name and args here
      # generate the setup code(type & parser) with possibly
      # compile time proc helpers
      # generate the flag code directly here
      # or with flag(..) which will be invoked later
      discard
    
    # if you demand autocompletion, this is a hack, but it's a very simple 
solution: and it describes correctly the flag function in your dsl
    proc flag*(names: varargs[string], help: string = "") =
      discard
    
    
    Run

If you demand flag to be explicitly defined, use a macro, not a compile time 
function: this way you can
    
    
    block:
      assign tmpParser
      flag(..)
    
    
    Run

and generate code working on tmpParser in flag . This way you'll have your 
macro mkParser and your macro flag with the right signature and autocompletion

Reply via email to