[antlr-interest] Removing output=AST lets ANTLR fail to generate

Sam Barnett-Cormack s.barnett-cormack at lancaster.ac.uk
Fri Nov 11 10:55:04 PST 2011


So, in other words, the feature request is that AST-related syntax be 
ignored if output!=AST?

Yeah, I could go for that, though I don't know if there would be 
complications deeper in implementation. Any tree-related action code, 
for instance, would be broken horribly. However, it would be a useful 
thing for very clean, pure lexing and parsing. The only thing I wonder 
is, for that not-generating-an-AST-any-more parser, wouldn't it need 
some different actions from the original AST-generating version in order 
to be any use whatsoever?

Sam

On 11/11/2011 17:51, Christian wrote:
> Waoh, your interpretation of my words really shocked me ;)
>
> I just asked if ANTLR could generate the lexer and parser without
> AST-code if the option output=AST is removed. Apparently, it is not
> possible so far. And please believe me, I was at no moment angry. But
> back to the topic:
>
> Feature request for ANTLR v4:
> *Context:*
> If you add AST shaping code to a given grammar and later change the
> grammar itself, too, you cannot directly generate a pure lexer and
> parser without AST shaping code anymore. You have to remove the AST
> shaping code from the grammar to do it.
> *Solution:*
> If a combined grammar contains AST shaping code, it would be more
> flexible if ANTLR is still able to generate non-AST target language code
> when, e.g., the option output=AST is not defined.
>
> I hope, my phrasing is better now ;)
>
> Best regards,
> Christian
>
> Am 11.11.2011 16:33, schrieb Jim Idle:
>> I think it might be the phrasing of your question. It may be a language
>> barrier issue, but it sounds like "You stupid ANTLR asshats, why can't you
>> do it this way, which is the way I expect it to work and so it must be the
>> correct way; you are all stupid!"
>>
>> But...
>>
>> Clearly, as you get an error telling you that you have AST shaping code in
>> there, then you cannot remove that option without removing the AST shaping
>> directives. Whether or not that can be improved is not very relevant as
>> 3.x is now in  maintenance mode while ANTLR 4 is being thrashed in to
>> shape. So, perhaps you can rephrase your statement in to a feature request
>> for ANTLR v4. It is a reasonable request if a little care is taken over
>> the phrasing.
>>
>>
>> Jim
>>
>>> -----Original Message-----
>>> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
>>> bounces at antlr.org] On Behalf Of Christian
>>> Sent: Friday, November 11, 2011 12:15 AM
>>> To: Eric; antlr-interest at antlr.org
>>> Subject: Re: [antlr-interest] Removing output=AST lets ANTLR fail to
>>> generate
>>>
>>>> As I understand it, you are creating a grammar and then remove
>>>> output=AST
>>> I created a combined grammar that contains operators and rewrite rules.
>>> When I then remove the option "output=AST", the grammar is not
>>> generated due to syntax errors. These syntax errors result from the
>>> operators and rewrite rules. You can reproduce it with any
>>> corresponding grammar you like.
>>>
>>> Christian
>>>
>>> Am 10.11.2011 18:33, schrieb Eric:
>>>> I don't believe that anyone here is avoiding your question. I my self
>>>> am unable to directly answer your question because it does not make
>>>> sense to me. As I understand it, you are creating a grammar and then
>>>> remove output=AST. Since you are expecting a lexer and parser as
>>>> output, I must take it that you  are using a combined grammar. Based
>>>> on the limited info given I see no reason why you are not getting an
>>>> lexer and parser. If you were to post your grammar and the steps you
>>>> take, someone here might spot something needing advise.
>>>>
>>>> Eric
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>      >  Hi community,
>>>>      >
>>>>      >  it seems that ANTLR cannot generate the lexer and parser if
>>>>      output=AST
>>>>      >  is removed, but the operators and rewrite rules are still left
>>>>      in the
>>>>      >  grammar. Am I right? If yes, that's really regrettable...and
>>>>      unflexible.
>>>>      >  You could just ignore rewrite rules and operators, if output !=
>>> AST,
>>>>      >  couldn't you?
>>>>      >
>>>>      >  Regards,
>>>>      >  Christian
>>>>
>>>>      List: http://www.antlr.org/mailman/listinfo/antlr-interest
>>>>      Unsubscribe:
>>>>
>>>> http://www.antlr.org/mailman/options/antlr-interest/your-email-
>>> address
>>>>
>>>
>>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>>> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
>>> email-address
>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>>
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address


More information about the antlr-interest mailing list