[bitc-dev] Implementation of indentation-aware parse

Jonathan S. Shapiro shap at eros-os.com
Thu Feb 26 22:04:34 EST 2009


On Thu, Feb 26, 2009 at 8:01 PM, Sam Mason <sam at samason.me.uk> wrote:
> Yes, I came to the same conclusion but from the point of view of what
> constraints would I need to apply to do it only in the lexer.  Nicely
> it matched what Geoffrey described.  I'd maintain some brace depth and
> ignore new lines when inside at least one brace.  A block open/close is
> returned when the indent depth increases/decreases respectively.  A bit
> grim, but seems like a simple enough hack.  Python gives the appropriate
> errors when I fail to follow these rules which is somewhat nice.

Something like that. It's not quite enough if blocks are expressions.
In effect, you have several types of lexically nested braces, and you
need to keep track of the innermost active brace type in the current
lexical context.

So there is a devil in the details, but yes, something like this ought
to work. And then the trick would be to have the lexer synthetically
emit OPEN/CLOSE tokens to the parser at the right points.

Makes me want to go sacrifice my dinner on the porcelain alter, but doable.

shap


More information about the bitc-dev mailing list