Is there a good, complete tutorial on Erlang parse

2019-01-13 01:00发布

问题:

There are lots of fragments out there detailing bits and pieces of the parse transform process in Erlang, but none I've found offer complete coverage from motivation to execution. Is there a good tutorial I'm missing somewhere and, if so, where can it be found?

回答1:

Checkout this series of blogposts on how to use parse transform capabilities of erlang to write a macro processor for erlang:

  • erlang-macro-processor-v1-part-i
  • erlang-macro-processor-v1-part-ii
  • erlang-macro-processor-v1-part-iii
  • erlang-macro-processor-v1-part-iv
  • erlang-macro-processor-v2-part-i
  • erlang-macro-processor-v2-part-ii
  • erlang-macro-processor-v2-part-iii
  • erlang-macro-processor-v2-part-iv
  • erlang-macro-processor-v2-part-v
  • erlang-macro-processor-v2-part-vi


回答2:

Please note that 'Programmers are strongly advised not to engage in parse transformations and no support is offered for problems encountered'. Sometimes it simplifies the process of writing new pieces of code but often breaks syntax checkers like flymake. In fact, I hate it, cause it adds a new layer of obfuscation when you trying to figure out what others did in source.



回答3:

These are made easy by using, https://github.com/uwiger/parse_trans