Parser Generator and Transpilator what’s the difference?

Asked

Viewed 60 times

2

While studying about compiler types I came across the term: Source-to-Source concerning the procedure for transpilation.

It turns out that some sections further down the term Parser-Generator and some synonyms as Compiler, Compiler-Generator emerged defining the same concept.

And here began a great confusion, after all Parser-Generator and Transpilator work the same way or is there difference ? If there’s a difference, what’s the difference between them ?

If possible leave references because I’m always reading, if possible also cite some parsers-generators.

1 answer

2


I will not talk about transpilation because it has already been explained in the question linked and because the subject has nothing to do with the other doubt, is like asking what the difference between steel and Fresadora, both are used in the production of a car, but have no direct relationship, and also explaining what is a generator parser it will become clear.

The other terms, in practice, are more or less synonymous (there may be some subtle difference, some do a little more than others) and indicate that you have a tool that helps you create compilers, especially the part of parser of him, which usually includes the lexer also.

A parser It is a laborious and tiring thing to do, as well as being easy to make a mistake. It’s hard to get around in code every time, and it’s mostly boring to experiment with grammar like this. Like parsers is the code that expresses to the computer how to handle grammar, if you have a pattern of how to express grammar in a more abstract way, but as a human can understand you can have a software that reads it and create the code of the parser following the rules of the grammars expressed previously in a non-programming language (usually some rod of BNF).

Then the generator of parser usually comes with a complete tool, an IDE to create a compiler, an example is ANTLR, the best known:

Screenshot do ANTLR

So you can test, try various forms of grammar, get all the information, see what goes wrong, and when you are satisfied and want to see it real it generates a code that will be used in the compiler, it is only then that the parsers Generator enters, it writes the code for you to use on the compiler, so you don’t have to worry about it.

In general the code is not the best, so in high-profile languages they are not used, IE, who wants performance, more power and flexibility in the language or generate better error messages, is not a good tool. But it’s very useful where you can’t spend too much time with the compiler or you’re just prototyping it.

The transpilator is already the compiler, so there is no comparison, it may be that a transpilator has been generated, in part, by a generator parser.

One could say that the parser generator is a transpilator, and then there would be no difference, it would just be a different way of classifying the same thing, but you can dispute that a little, strictly true, but the objectives are different, would fit a debate, not here.

Should interest:

  • Excellent answer, it made many doubts about what I thought about a parser... although my thinking started from this premise: "One could say that the parser generator is a transpilator, and then there would be no difference, it would just be a different way of classifying the same thing, but one can dispute this a little, strictly true, but the objectives are different, it would fit a debate, not here." ; But once, thank you very much.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.