DEV Community

Discussion on: What developer products/tools should exist, but don't?

Collapse
 
hoffmann profile image
Peter Hoffmann

Syntactic translators:

  • Want to indent instead of using braces like in Python?
  • Prefer function arguments with spaces instead of commas and without braces like in Bash?
  • Like the arrow between object and method/property as in PHP?

All that shouldn't be something the language dictates but just your personal flavor. I'd like to opt between these possibilities (and probably many more, append below).

Collapse
 
hotfusionman profile image
Al Chou

I experimented with ANTLR to insert the missing end statements when parsing Python and outputting Ruby equivalent. I guess what you would want is to be able to easily plug a parser for one language into a central engine that would have an output plugin for the target language -- the central engine storing the AST or something like that. It wouldn't necessarily be possible for all pairs of languages, but you did say "syntactic", so I think I can omit imperative-to-functional language translation. And then the next step is to make the plugins more granular, so that you wouldn't have to say "input is PHP, output is Bash" but "translate arrow attribute access operator to native accessor syntax of target language-feature-set".

Lisps with reader macro capability allow you to define your own syntax additions, but that is an advanced skill, and the syntax probably can't stray too far from the original -- you're never going to get rid of those Insignificant Silly Parentheses with just reader macros.