How do I start writing a transpiler? Is it even possible?

后端 未结 3 1145
臣服心动
臣服心动 2020-12-23 15:21

Due to confidentiality reasons, I might not be able to describe in pin point details but here is the scenario.

Various devices that have streaming apps have differen

3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-23 15:57

    Yes, this is possible, and compilers are often written this way.

    The general idea is to create an "intermediate language", then write several one-way translators:

      C#           => intermediate
      JavaScript   => intermediate
    
      intermediate => C#
      intermediate => JavaScript
    

    Putting the output from one, into the next, you can translate from one language to another:

      C#          =>  intermediate =>  JavaScript
      JavaScript  =>  intermediate =>  C#
    

    Unfortunately the code generated will probably not be human-friendly.

提交回复
热议问题