Inconsistant line break parsing
Monkey Forums/Monkey Programming/Inconsistant line break parsing
| ||
I noticed while writing something the other night that the parser had a syntax error with "Error: Syntax error -expecting ')'." The error is arising from something inconsistent in line break parsing. Working Strict Function Main:Int() Local a:Int = 1, b:Int = 2, c:Int = 3, d:Int = 4 If ( a < b And c < d And a < d ) Print "Hmm" End Return 0 End Not working Strict Function Main:Int() Local a:Int = 1, b:Int = 2, c:Int = 3, d:Int = 4 If ( a < b And c < d And a < d ) Print "Hmm" End Return 0 End OR Working Strict Function Main:Int() Local a:Int = 1, b:Int = 2, c:Int = 3, d:Int = 4 Return 0 End Not Working Strict Function Main:Int() Local a:Int = 1, b:Int = 2 ,c:Int = 3, d:Int = 4 Return 0 EndWhile I know line breaks are used to end statements, and that most people wouldn't write code like this; I can see where a parsing error could arise. However, the inconsistency looks really bad in that it's not a syntax error so to speak if the other is okay. EDIT: Same thing is happening with arrays. Except with "Syntax error - expecting ']'." |
| ||
The operator ( AND OR , ) must be the last item on the line. |
| ||
I know how it parses it. My point is that it's inconsistent. If you're going to bother to allow line breaks to separate content, then the code should be parsed as such to allow whitespace to proceed before assuming the next line must be a new statement. At least with BlitzMax it had ".." to separate lines so that you could freely separate lines. I've written a handful of parsers and this is possible to change. Edit: I should note that I found no documentation regarding line breaks. |
| ||
As an aside, @Goodlookinguy I'm following your monkey e-book with great interest. Keep up the good work. |
| ||
Hi, Multi-line lines must currently end with an 'operator' (+, -, and, or etc) or a comma. This may or may not be relaxed at a later date, but for now them's the rulez! Docs will be updated soon to reflect this. |