Closed mbakeranalecta closed 7 years ago
This was actually a bug in the code that displays where the error occurred, so it was trying to say were the problem was, it just did not get that far.
The error is was trying to display is "A RecordSet can only have Record children." In this case the pickiness was not about indents per se. Indents indicate hierarchy, so anything that is indented under a recordset has to be treated as a record, and since the sentence was not a valid record, it did not meet that criteria.
This is fixed in 7a691fa823ac0365a16214f61d6072e1d314865b
From Richard Hamilton:
Hi Mark,
I just finished chasing down a tricky problem.
By accident, I inserted an extra space in the first paragraph of a .sam file. That is, I created the following:
There are five spaces, instead of four, before the word “What”. I’ve included the error messages below.
I’m surprised that the syntax is that picky, but also, I’m a bit concerned that unlike some of the other error messages I’ve seen, this one doesn’t identify the line in the input file that triggered the error. I needed to do a divide and conquer test to find the offending spot (I kept splitting the file in half until I found the problem).
I played around a bit, and I like that the only concern is consistency (that is, I can make the size of the indent pretty much anything at each level, as long as everything else at the same level has the same indent), but it would be helpful to have better diagnostics for this kind of thing (which is probably pretty common).
Best regards, Richard
P.S. No need to do anything while you’re away; I’ve got things running again, and I’m sure I can diagnose anything similar that occurs, but I wanted you to know about this.
Here is the error message:
SAM parser information: Parsing /Users/hamilton/src/Baker/structuredwritingbook/sam/testpart.sam SAM parser information: Parsing include annotations.sam SAM parser information: Finished parsing include annotations.sam Traceback (most recent call last): File "/Users/hamilton/src/Baker/sam/samparser.py", line 2312, in
samParser.parse(inf)
File "/Users/hamilton/src/Baker/sam/samparser.py", line 105, in parse
self.stateMachine.run((self.source, None))
File "/Users/hamilton/src/Baker/sam/statemachine.py", line 25, in run
(newState, cargo) = handler(cargo)
File "/Users/hamilton/src/Baker/sam/samparser.py", line 189, in _paragraph_start
self.doc.add_block(b)
File "/Users/hamilton/src/Baker/sam/samparser.py", line 1275, in add_block
self.current_block.add(block)
File "/Users/hamilton/src/Baker/sam/samparser.py", line 560, in add
self.parent.add(b)
File "/Users/hamilton/src/Baker/sam/samparser.py", line 755, in add
str(self)))
File "/Users/hamilton/src/Baker/sam/samparser.py", line 597, in str
return ''.join(self._output_block())
File "/Users/hamilton/src/Baker/sam/samparser.py", line 606, in _output_block
yield str(x)
File "/Users/hamilton/src/Baker/sam/samparser.py", line 597, in str
return ''.join(self._output_block())
File "/Users/hamilton/src/Baker/sam/samparser.py", line 777, in _output_block
yield " " * int(self.indent + 4) + x[0] + ' = ' + x[1] + "\n"
TypeError: Can't convert 'Flow' object to str implicitly