[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Ada-mode-users] Indenting incomplete code during editing
From: |
WAROQUIERS Philippe |
Subject: |
Re: [Ada-mode-users] Indenting incomplete code during editing |
Date: |
Wed, 2 Nov 2016 15:03:23 +0000 |
> 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.
>
> > But I might be wrong. Any opinions? Suggestions? Solutions?
>
> There are two approaches that make sense here; defining two (or more)
> levels of grammar, and adding intelligent (grammar-completing) error
> handling to the parser.
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' ?
>
> GPS uses a third approach; a recursive-descent parser. That allows
> halting the parse at any point, while providing complete parse
> information before that point. Recursive-descent parsers are not
> generated from grammars; they are written by hand. I wanted a parser
> that was at least close to the defined language grammer (to make it easy
> to adapt when the language changes), and adaptable to other languages
> (gpr, in particular).
>
> 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 ?
Thanks
Philippe
One of the users which is perturbed a lot with the ada-mode 5 behaviour in
presence of parsing error :)
____
This message and any files transmitted with it are legally privileged and
intended for the sole use of the individual(s) or entity to whom they are
addressed. If you are not the intended recipient, please notify the sender by
reply and delete the message and any attachments from your system. Any
unauthorised use or disclosure of the content of this message is strictly
prohibited and may be unlawful.
Nothing in this e-mail message amounts to a contractual or legal commitment on
the part of EUROCONTROL, unless it is confirmed by appropriately signed hard
copy.
Any views expressed in this message are those of the sender.
- Re: [Ada-mode-users] Indenting incomplete code during editing,
WAROQUIERS Philippe <=