my_basic icon indicating copy to clipboard operation
my_basic copied to clipboard

REM and ENDREM as comment blocks

Open blazer2k1 opened this issue 1 year ago • 2 comments

I thought it would be more consistent to just use REM and ENDREM as comment blocks instead of '[ and '] which looks more like arrays. The syntax already has REM as a single line comment.

If there's no plan to change this, perhaps you could provide some pointers on how to do this update.

Reference: https://picaxe.com/basic-commands/directives/hash-endrem/

blazer2k1 avatar Oct 02 '23 07:10 blazer2k1

  1. Change https://github.com/paladin-t/my_basic/blob/67ef347023fccdeae1081fce9c86d0bf176997a1/core/my_basic.c#L773-#L774 to
MBCONST static const char _MULTI_LINE_COMMENT_PREFIX[] = "'REM";
MBCONST static const char _MULTI_LINE_COMMENT_POSTFIX[] = "'ENDREM";

to use 'REM and 'ENDREM.

  1. Change the comparison from
c == _MULTI_LINE_COMMENT_PREFIX[context->multi_line_comment_count++]
...
c == _MULTI_LINE_COMMENT_POSTFIX[context->multi_line_comment_count++]

to

toupper(c) == _MULTI_LINE_COMMENT_PREFIX[context->multi_line_comment_count++]
...
toupper(c) == _MULTI_LINE_COMMENT_POSTFIX[context->multi_line_comment_count++]

for case-insensitive.

  1. Change the symbols in 1. to #REM and #ENDREM, then change https://github.com/paladin-t/my_basic/blob/67ef347023fccdeae1081fce9c86d0bf176997a1/core/my_basic.c#L5053-#L5055 to
static bool_t _is_comment_char(char c) {
	return (c == '\'') || (c == '#');
}

to use #REM and #ENDREM instead. Note that this also enables # for a single-line comment.

paladin-t avatar Oct 03 '23 12:10 paladin-t

Thanks, but I was aiming for not using symbols before the keyword for this change so without ' or # just plain REM and ENDREM.

blazer2k1 avatar Oct 03 '23 18:10 blazer2k1