AlternateLayoutRule
John Meacham
john at repetae.net
Wed May 14 20:16:11 UTC 2014
Actually, it has less cases than my previous version, I think I just
wasn't presenting it well. My goal is to make something that will
accept current programs out there _and_ be much simpler than the
current rule. The parse exception brings a huge amount of complexity
into the old rule. LALR parsers are notoriously tricky for even
experienced programmers.
So, compared to the H98 rule the major simplification is:
Rather than extend layout until the language parser encounters an
error, I proactively disable layout when inserting a semi or brace
would guarentee a parse error under a simple parsing algorithm that
only keeps track of 'nesting level' and nothing else.
So, we basically just keep track of when inserting a semi or close
brace would cause an error of the form '(' with no matching ')' found
and don't do it then.
which state your automata goes to next depends on simple pattern
matching on current symbol and current top of stack and can be listed
as a set of tuples.
in other words, a textbook deterministic push down automaton.
John
On Wed, May 14, 2014 at 7:29 AM, Ian Lynagh <igloo at earth.li> wrote:
> On Tue, May 13, 2014 at 11:20:25PM -0700, John Meacham wrote:
>> Okay, I believe I have come up with a modified version that accepts many more
>> programs and doesn't require complicated comma handling, you can make all
>> decisions based on the top of the context stack. It also allows many useful
>> layouts that were illegal under the old system.
>
> From your description, the rule still sounds quite complex. It depends
> whether the objective is a rule that is close enough to the current rule
> that we can switch with very little code breaking, or a rule that is
> simple to explain to newcomers to the language (but which will require
> much more code tweaking when updating packages to compile with the new
> standard).
>
>
> Thanks
> Ian
>
--
John Meacham - http://notanumber.net/
More information about the Glasgow-haskell-users
mailing list