added block comment /* ...... */

This commit is contained in:
Irmen de Jong 2023-07-04 00:18:58 +02:00
parent be64fa674a
commit 5af1aeb092
4 changed files with 21 additions and 11 deletions

View File

@ -20,8 +20,11 @@ Module
A module file can *import* other modules, including *library modules*.
Comments
Everything after a semicolon ``;`` is a comment and is ignored by the compiler. There is no block-comment.
Everything on the line after a semicolon ``;`` is a comment and is ignored by the compiler.
If the whole line is just a comment, this line will be copied into the resulting assembly source code for reference.
There's also a block-comment: everything surrounded with ``/*`` and ``*/`` is ignored and this can span multiple lines.
This block comment is experimental for now: it may change or even be removed again in a future compiler version.
The recommended way to comment out a bunch of lines remains to just bulk comment them individually with ``;``.
Directive
These are special instructions for the compiler, to change how it processes the code

View File

@ -20,13 +20,19 @@ You can use tabs or spaces as you wish.
Source code comments
^^^^^^^^^^^^^^^^^^^^
Everything after a semicolon ``;`` is a comment and is ignored. There is no block-comment so just
comment out each individual line if you want to comment out a bunch of them.
Everything on a line after a semicolon ``;`` is a comment and is ignored.
If the whole line is just a comment, it will be copied into the resulting assembly source code.
This makes it easier to understand and relate the generated code. Examples::
This makes it easier to understand and relate the generated code.
Everything surrounded with ``/*`` and ``*/``, this can span multiple lines, is a block-comment and is ignored.
This block comment is experimental for now: it may change or even be removed again in a future compiler version.
Examples::
counter = 42 ; set the initial value to 42
; next is the code that...
/* this
is
all
ignored */
.. _directives:

View File

@ -19,6 +19,7 @@ package prog8.parser;
EOL : ('\r'? '\n' | '\r' | '\n')+ ;
LINECOMMENT : EOL [ \t]* COMMENT -> channel(HIDDEN);
COMMENT : ';' ~[\r\n]* -> channel(HIDDEN) ;
BLOCK_COMMENT : '/*' ( BLOCK_COMMENT | . )*? '*/' -> skip ;
WS : [ \t] -> skip ;
// WS2 : '\\' EOL -> skip;
@ -31,11 +32,11 @@ ADDRESS_OF: '&' ;
INVALID_AND_COMPOSITE: '&&' ;
FLOAT_NUMBER : FNUMBER (('E'|'e') ('+' | '-')? DEC_INTEGER)? ; // sign comes later from unary expression
fragment FNUMBER : FDOTNUMBER | FNUMDOTNUMBER ;
fragment FDOTNUMBER : '.' ('0'..'9')+ ;
fragment FNUMDOTNUMBER : ('0'..'9')+ ('.' ('0'..'9')+ )? ;
FNUMBER : FDOTNUMBER | FNUMDOTNUMBER ;
FDOTNUMBER : '.' ('0'..'9')+ ;
FNUMDOTNUMBER : ('0'..'9')+ ('.' ('0'..'9')+ )? ;
fragment STRING_ESCAPE_SEQ : '\\' . | '\\x' . . | '\\u' . . . .;
STRING_ESCAPE_SEQ : '\\' . | '\\x' . . | '\\u' . . . .;
STRING :
'"' ( STRING_ESCAPE_SEQ | ~[\\\r\n\f"] )* '"'
;

View File

@ -2,8 +2,8 @@
<highlighting>
<options>
<option name="LINE_COMMENT" value=";" />
<option name="COMMENT_START" value="{{" />
<option name="COMMENT_END" value="}}" />
<option name="COMMENT_START" value="/*" />
<option name="COMMENT_END" value="*/" />
<option name="HEX_PREFIX" value="$" />
<option name="NUM_POSTFIXES" value="" />
<option name="HAS_BRACES" value="true" />
@ -20,4 +20,4 @@
<mapping ext="p8" />
<mapping ext="prog8" />
</extensionMap>
</filetype>
</filetype>