This project has moved and is read-only. For the latest updates, please go here.

Multiline list of identifiers with white spaced scoping.

Jun 6, 2015 at 9:48 PM
First, great job on this tool: it's excellent.

I'm using it to implement a custom language compiler for my final year BSC project. I've been making good progress adapting the minipython sample, but am stuck on one thing: I would like to have multiline lists without the line continuation symbol or having the list in braces. An example of a code snippet that I can't get to parse:
class foo of T, 
This gives the syntax error expected: identifier.

The following two pieces of code parse correctly:
class foo of T, \

class foo of (T, 
I feel like I'm missing something obvious. Is there a way to tell the parser that if a line ends in a comma, continue onto the next line regardless of whether we're currently inside parantheses?
Jun 8, 2015 at 6:37 AM
you might try to hook to ValidateToken event of NewLine terminal - you can analyse the parsing state in code (last processed token, and stack of braces) and let NewLine pass to Parser automaton, or reject it (skip it) - you may need to move source position beyond the new line chars.
Jun 8, 2015 at 11:04 AM
Thanks for the reply!

It doesn't seem that the ValidateTokent even for NewLine (or Eos, which I also tried) triggers. I was able to get it to trigger with other tokens. I imagine that this is an issue with whitespaced parsing?

Regardless, it's alright: I reworked the syntax so that the scenario I described doesn't happen, and I actually prefer the change.
Jun 9, 2015 at 4:05 AM
Hello again, just figured I'd mention, in case any one else encounters this scenario:

The problem is fixed by registering the comma as an operator, and having OutlineOptions.CheckOperator set in the CodeOutlineFilter (see the minipython example to see where this is). Comma separated lists still appear to work, and at the same time, when the parser encounters a comma at the end of a line, it automatically continues on the next line. Kind of a cheap hack, but it works so I'm happy :)