ada-mode-users
[Top][All Lists]
Advanced

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

Re: [Ada-mode-users] Indenting incomplete code during editing


From: Stephen Leake
Subject: Re: [Ada-mode-users] Indenting incomplete code during editing
Date: Wed, 02 Nov 2016 14:28:12 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (windows-nt)

WAROQUIERS Philippe <address@hidden> writes:

>> That is the approach Ada mode 4.0 used. It becomes extremely unweildy
>> when you try to cover all the cases; that's why Emacs Ada mode 5.0 and
>> GPS use parser-based indentation.
>>
>> It would be possible to handle a few special cases. but there would
>> always be pressure to handle more, so I'd rather not go down that road.
>>
> Alternatively, can't we keep the ada-mode 4.0 parsing and indenting
> engine/approach (maybe slightly reworked) to handle the case of 'local
> indentation when parsing fails' ?

We can't keep the ada-mode 4.0 code literally; it conflicts too much
with the 5.0 code. So it would have to be re-implemented.

It might be worth fixing the main "missing end block" cases that way,
and see if that's good enough.

>> For two levels of grammar, we'd define the top level to contain only
>> block keywords; declare/begin/end, if/then/else/end if, etc. Everything
>> else would be treated as filler. The lower level would be the current
>> complete grammar, but it would be applied inside each high-level block
>> separately.
>>
>> This strategy is used by the semantic-based parsers in some other Emacs
>> language modes; typically, the high level grammar is { }, which does not
>> work well for Ada ):.
>>
>> This would _not_ handle adding "if" without "end if", but it would
>> isolate the bad indentation to the enclosing block.
>>
>>
>> For grammar-completing error handling, try to add the missing tokens to
>> complete the current grammar statement; add an implicit "end if".
>>
>> The two approaches could be combined; it might be easier to decide what
>> tokens to add in the high level grammar.
>>
>> I have not done any work towards either approach.
>> 
> Do you have an idea/guesstimate of the effort involved ? Do we speak
> days, weeks, months ?

I'm guessing 50 hours work for a proof of concept for the
grammar-completing error approach; I'd implement that by hand in the
parser for the "missing end if" case, then investigate generalizing that
and adding more info to the grammar source so it could be implemented by
the grammar generator.

If anyone wants to fund that work, it's _much_ more likely to happen.

-- 
-- Stephe



reply via email to

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