bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 3/4] java: add support for lookahead correction


From: Adrian Vogelsgesang
Subject: Re: [PATCH 3/4] java: add support for lookahead correction
Date: Wed, 4 Nov 2020 09:00:04 +0000
User-agent: Microsoft-MacOutlook/16.42.20101102

Interesting…. Good that there was a test case for that! :)

From: Akim Demaille <akim.demaille@gmail.com>
Date: Wednesday, 4. November 2020 at 07:17
To: Akim Demaille <akim.demaille@gmail.com>
Cc: Adrian Vogelsgesang <avogelsgesang@tableau.com>, "bison-patches@gnu.org" 
<bison-patches@gnu.org>
Subject: Re: [PATCH 3/4] java: add support for lookahead correction

Hi Adrian,

> Le 2 nov. 2020 à 07:32, Akim Demaille <akim.demaille@gmail.com> a écrit :
>
>> Le 2 nov. 2020 à 01:50, Adrian Vogelsgesang <avogelsgesang@tableau.com> a 
>> écrit :
>>
>> public 
>> ]b4_parser_class[(]b4_parse_param_decl([b4_lex_param_decl])[)]b4_maybe_throws([b4_init_throws])[
>> {
>> -]b4_percent_code_get([[init]])[
>> - this.yylexer = new YYLexer (]b4_lex_param_call[);
>> +]b4_percent_code_get([[init]])[]b4_lac_if([[
>> + this.yylacStack = new Vector<Integer>();
>> + this.yylacEstablished = false;]])[
>> + this.yylexer = new YYLexer(]b4_lex_param_call[);
>> ]b4_parse_param_cons[
>>
>>
>> Why do we place the user-provided init-code first?
>> Does that mean, the user must not call any methoes which might depend on 
>> `yylexer`?
>> Not sure if this actually matters, but I would put the user-provided 
>> init-code last, so that the rest of the class is already initialized…
>
> It makes sense, I'll change that. Thanks!

Well, it turns out that this was by design, to be able to call 'super'.
When I tried that change, the test suite failed:

> http://YYParser.java:294<http://YYParser.java:294> error: call to super must 
> be first statement in constructor
> super("Test Thread"); if (true) throw new InterruptedException();
> ^


That's test 682, http://java.at:470<http://java.at:470>, Java constructor init 
and init_throws:

> m4_pushdef([AT_Witness],
> [super("Test Thread"); if (true) throw new InterruptedException();])
>
> AT_CHECK_JAVA_MINIMAL([[
> %define extends {Thread}
> %code init { ]AT_Witness[ }
> %define init_throws {InterruptedException}
> %lex-param {int lex_param}]])
> AT_CHECK([[grep ']AT_Witness[' YYParser.java]], 0, [ignore])

And it's documented:

> Use @code{%code init} for code added to the start of the constructor
> body. This is especially useful to initialize superclasses. Use
> @samp{%define init_throws} to specify any uncaught exceptions.


Cheers!

reply via email to

[Prev in Thread] Current Thread [Next in Thread]