ANTLR4 to SmaCC

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

ANTLR4 to SmaCC

Henrique Rocha
Hello,

I was trying to convert a ANTLR4 grammar specification to SmaCC. After many unsuccessful tries that made me question my sanity I wondered: maybe someone has a solution. Grammar conversion is something that can be automated.

My question is if anyone has done something to convert an ANTLR4 grammar to a SmaCC grammar?

Thanks and farewell,

- Henrique
Reply | Threaded
Open this post in threaded view
|

Re: ANTLR4 to SmaCC

abergel
Hi Henrique,

I have never tried to do this. But this is a very valuable effort. There are many grammars in ANTLR, it would be fantastic to reuse them.

Keep us posted about your efforts.

Alexandre
-- 
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.



On May 31, 2017, at 11:03 AM, Henrique Rocha <[hidden email]> wrote:

Hello,

I was trying to convert a ANTLR4 grammar specification to SmaCC. After many
unsuccessful tries that made me question my sanity I wondered: maybe someone
has a solution. Grammar conversion is something that can be automated.

My question is if anyone has done something to convert an ANTLR4 grammar to
a SmaCC grammar?

Thanks and farewell,

- Henrique



--
View this message in context: http://forum.world.st/ANTLR4-to-SmaCC-tp4948738.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.


Reply | Threaded
Open this post in threaded view
|

Re: ANTLR4 to SmaCC

Thierry Goubier
In reply to this post by Henrique Rocha
Hi Henrique,

Le 31/05/2017 à 17:03, Henrique Rocha a écrit :
> Hello,
>
> I was trying to convert a ANTLR4 grammar specification to SmaCC. After many
> unsuccessful tries that made me question my sanity I wondered: maybe someone
> has a solution. Grammar conversion is something that can be automated.

Sort of.

LL(*) brings itself to entirely different hacks to play with the tokens
and lexical analysis that LR() grammars, and most of the hard work on
parsers is in that area.

I haven't looked if the reversed recursion in ANTLR is hard to convert.

The use of the + * ? [ ] symbols is nice because it hides effectively on
which side the recursion happens (left recursion in LR, right recursion
in ANTLR)

> My question is if anyone has done something to convert an ANTLR4 grammar to
> a SmaCC grammar?

Write a ANTLRv4 grammar syntax grammar in SmaCC would do the trick.

Apart from semantic actions of course.

Regards,

Thierry

> Thanks and farewell,
>
> - Henrique
>
>
>
> --
> View this message in context: http://forum.world.st/ANTLR4-to-SmaCC-tp4948738.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>
>


Reply | Threaded
Open this post in threaded view
|

Re: ANTLR4 to SmaCC

Henrique Rocha
Thierry Goubier wrote
LL(*) brings itself to entirely different hacks to play with the tokens
and lexical analysis that LR() grammars, and most of the hard work on
parsers is in that area.

I haven't looked if the reversed recursion in ANTLR is hard to convert.
I agree. But I have seem some tricks and tips to convert one kind to the other. It seems like a lot of the work can be automated.

Thierry Goubier wrote
Write a ANTLRv4 grammar syntax grammar in SmaCC would do the trick.
Unfortunately, I dont have the skills or the knowledge in SmaCC to write this in SmaCC. I tried and failed (so many times) to convert a specific language to SmaCC and I got nowhere (I cant even imagine to do a more generic syntax grammar such as ANTLR).

That is why I am asking for help if anyone else has done something like that.

Thanks and best regards,

- Henrique