bcc icon indicating copy to clipboard operation
bcc copied to clipboard

@bmk Pragma broken since 0.139

Open Scaremonger opened this issue 10 months ago • 0 comments

Bug Report

Consider the following code that includes simple Pragmas: `SuperStrict

' @bmk echo ' @bmk echo ******************************* ?Debug ' @bmk echo **** DEBUG MODE ?Not Debug ' @bmk echo **** RELEASE MODE ? ' @bmk echo *******************************

Print "Hello World"`

Expected Behavior

In version 0.138 this would print "DEBUG MODE" or "RELEASE MODE" during compilation, but since 0.139 this no longer works.

Actual Behavior

Compile Error: Expecting expression but encountered '' @bmk echo

[/home/si/dev/Blitzmax-Language-Server/bls-test.bmx;3;0]
Build Error: failed to compile (65280) /home/si/dev/Blitzmax-Language-Server/bls-test.bmx
Process complete

Environment

  • Operating System: Linux x64
  • Output of bcc -v: I have tried versions 0.136 (working), 0.138 (working/official), 0.139 (broken), 0.140 (broken), 0.142 (broken) and 0.143 (latest/broken)
  • Optional additional info, download, project links, etc

Investigation

In file parser.bmx within method TParser.ParseMain(): Existing Code in 0.143

		'Parse header - imports etc.
		While _toke
			SetErr
			Select _toke.ToLower()
...
			Case "moduleinfo"
				NextToke
				Local info:String = ParseStringLit()
				_module.modInfo.AddLast(info)
			Default
				Exit
			End Select

			If _tokeType = TOKE_PRAGMA Then
				ParsePragmaStmt()
				NextToke
			End If
		Wend

The Default at the end of the select..case, exits before it gets to the PRAGMA parser. I fixed it by moving the pragma parser into the default like this: Potential fix

		'Parse header - imports etc.
		While _toke
			SetErr
			Select _toke.ToLower()
...
			Case "moduleinfo"
				NextToke
				Local info:String = ParseStringLit()
				_module.modInfo.AddLast(info)
			Default
				If _tokeType = TOKE_PRAGMA Then
					ParsePragmaStmt()
					NextToke
				Else
					Exit
				End If
			End Select
		Wend

Scaremonger avatar Apr 07 '24 08:04 Scaremonger