April 25, 2019, 04:23:38 AM

Author Topic: comment bug  (Read 119 times)

Offline Cody

  • Jr. Member
  • **
  • Posts: 3
    • Raider
comment bug
« on: March 28, 2019, 12:52:36 AM »
If there is a better place to report a bug please let me know.
This may be an undocumented feature but if a comment has exclamation marks after a comment single quote the compiler treats it as code and not as a comment. The exact compiler error depends on where it is in the file and it is usually a strange kind of error. Words in the comment are treated as program code instead of a comment. This is not a big problem, simply put a space before any exclamation marks, but I wanted to report what had happened.

Offline fielder

  • Jr. Member
  • **
  • Posts: 65
Re: comment bug
« Reply #1 on: April 02, 2019, 08:34:12 AM »
If there is a better place to report a bug please let me know.
This may be an undocumented feature but if a comment has exclamation marks after a comment single quote the compiler treats it as code and not as a comment. The exact compiler error depends on where it is in the file and it is usually a strange kind of error. Words in the comment are treated as program code instead of a comment. This is not a big problem, simply put a space before any exclamation marks, but I wanted to report what had happened.
i'm using a lot of exclamation marks on my comments... without any issue.. can you post (the part of) the code?

Offline Derron

  • Hero Member
  • *****
  • Posts: 1953
Re: comment bug
« Reply #2 on: April 02, 2019, 09:08:15 AM »
Code: BlitzMax
  1. SuperStrict
  2. Framework Brl.StandardIO
  3.  
  4. '!print "hi"
  5.  

Output:
Code: [Select]
Building untitled1
[ 11%] Processing:untitled1.bmx
[ 90%] Compiling:untitled1.bmx.console.debug.linux.x64.c
/home/ronny/Arbeit/Programmieren/Tools/BlitzMaxNG/tmp/.bmx/untitled1.bmx.console.debug.linux.x64.c: In function ‘_bb_main’:
/home/ronny/Arbeit/Programmieren/Tools/BlitzMaxNG/tmp/.bmx/untitled1.bmx.console.debug.linux.x64.c:18:3: error: ‘print’ undeclared (first use in this function)
   print "hi"
   ^
/home/ronny/Arbeit/Programmieren/Tools/BlitzMaxNG/tmp/.bmx/untitled1.bmx.console.debug.linux.x64.c:18:3: note: each undeclared identifier is reported only once for each function it appears in
/home/ronny/Arbeit/Programmieren/Tools/BlitzMaxNG/tmp/.bmx/untitled1.bmx.console.debug.linux.x64.c:18:9: error: expected ‘;’ before string constant
   print "hi"
         ^
Build Error: failed to compile (256) /home/ronny/Arbeit/Programmieren/Tools/BlitzMaxNG/tmp/.bmx/untitled1.bmx.console.debug.linux.x64.c
Process complete


so why does that happen?

bcc.git/toker.bmx:
Code: BlitzMax
  1.                 Else If str="'"
  2.                         Local _tstr:String = TSTR()
  3.                         If _tstr="!" Then
  4.                
  5.                                 _tokeType=TOKE_NATIVE
  6.                                
  7.                                 While _tstr
  8.                                         If _tstr="~n" Then
  9.                                                 _tokePos:-1
  10.                                                 Exit
  11.                                         End If
  12.                                         _tokePos:+1
  13.                                         _tstr = TSTR()
  14.                                 Wend
  15.  

-> any comment starting with "'!" is handled as "native" which I assume means is "C" code.



So this now works:
Code: BlitzMax
  1. SuperStrict
  2. Framework Brl.StandardIO
  3.  
  4. '!printf("hi");
  5.  

bye
Ron