Inconsistant line break parsing

Monkey Forums/Monkey Programming/Inconsistant line break parsing

Goodlookinguy(Posted 2011) [#1]
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
End
While 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 ']'."


therevills(Posted 2011) [#2]
The operator ( AND OR , ) must be the last item on the line.


Goodlookinguy(Posted 2011) [#3]
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.


matt(Posted 2011) [#4]
As an aside, @Goodlookinguy I'm following your monkey e-book with great interest. Keep up the good work.


marksibly(Posted 2011) [#5]
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.