noord
New Member
Posts: 6
|
Post by noord on Dec 23, 2015 3:43:53 GMT 1
Hi, I am not sure? it is a bug or not.
static and -z BaCon 3.22 beta
bacon -y -z c.bac
got the message:
Compiler error:
Description: file 'c.bac.bac' line 3: LOCAL A TYPE int ARRAY 2 static Cause: expected ‘)’ before ‘static’
function F1 local A type int array 2 static A[0] = 1 A[1] = 2 return A end function
If I change static to STATIC, it works!
BaCon version 3.22 beta
bacon -y -j -z b.bac
the message: 'Syntax error: could not parse line 1 in file 'b.bac': "#define say PRINT"
rem BaCon version 3.22 beta
#define say print say 567
Thanks!
|
|
|
Post by Pjot on Dec 23, 2015 21:47:20 GMT 1
Hi noord, (1) Here we see one of the limitations of mixing BASIC keyword with C keywords. The keyword STATIC can be used in BaCon, but also in C, where it has a meaning for declaring static C variables. A similar problem for int / INT. The '-z' option capitalizes BaCon keywords by using the C Pre Processor. So the C Pre Processor (CPP) will just capitalize every instance of the 'STATIC' keyword. But as soon as it would encounter 'local p type static int' for example, the capitalized STATIC INT will be passed to the C compiler. And this will generate an error. You can use small letters, but this may lead to problems when using 'int' and 'static'. For this reason, the default is using capitalized keywords in your BaCon source code. This also will prevent accidental name mangling with existing C functions from external libraries. (2) You currently cannot use the -z and the -j option at the same time. The reason is again the very same C Pre Processor. In case of the '-z' option, additional tokens are added to the beginning and end of each source line. This is to prevent unwanted C style formatting which messes up error reporting. However, this also prevents processing macros in a correct way. Not sure if it can be worked around, but I will look further into this issue. Thanks and regards, Peter
|
|
noord
New Member
Posts: 6
|
Post by noord on Dec 24, 2015 9:39:37 GMT 1
Thanks Pjot! Thanks for your explanation. That make me feel i ask stupid question here. I need to read the doc more. Do I? thanks!
|
|
|
Post by Pjot on Dec 25, 2015 17:22:38 GMT 1
Hi noord, For item (1), the discussion about using small letters has come up in this forum a couple of times (see here and here). Also the BaCon website mentions that using capitals is the default (section FAQ). It simply is in the nature of a BASIC to C converter that name clashes and keyword conflicts can come up. For item (2), it is solved in the latest beta. Please let me know if this works for you. Thanks and regards Peter
|
|