5

Is it possible to write an Antlr code generation target for Erlang?

Tat-Yuen Hui
  • 141
  • 1
  • 6
  • 2
    of course , you can write any compiler with ANTLR but you need grammar for this language – Sajad Bahmani Dec 20 '09 at 09:59
  • if you mean you want to generate Erlang code to parse something using Antlr then yes it is possible, you can write something to generate whatever code you want. –  Dec 20 '09 at 18:33

3 Answers3

5

It depends what you mean. If you mean you want to generate parser & lexer source files in Erlang, then no, this is not possible (at least, not out of the box*). Checkout the current list of targets for ANTLR: http://www.antlr.org/wiki/display/ANTLR3/Code+Generation+Targets

* You could be the one implementing it, of course. But that's no trivial task!

Bart Kiers
  • 166,582
  • 36
  • 299
  • 288
1

Erlang comes with its own parse tools. They use their own syntax though, so you cant take a grammar file from antlr.

Christian
  • 9,417
  • 1
  • 39
  • 48
0

Sure, ANTLR is general purpose. If you really wanna do that, you should take a look at the Core Erlang language specification. Be warned that it is quite old, but should be okay for a starter.

Zed
  • 57,028
  • 9
  • 76
  • 100
  • 2
    It is **much** nicer to generate Core erlang than normal erlang as it is a smaller simpler language. I do it for LFE. The main problem is that it is not as stable as erlang as they tend to view it as an internal compiler pass. I am trying to get them to change that though. – rvirding Dec 22 '09 at 00:18