Source Files and Comments
LunarBasic source code is read one line at a time. Before parsing begins, blank lines and comments are removed so the parser can focus on real code.
Back to Language Reference
How Source Files Are Read
- Source is read line-by-line.
- Parsing works on logical source lines after blank lines and comments are removed.
- Error messages include the file name, line number, and column number.
Whitespace
- Whitespace between tokens is ignored.
- Blank lines are ignored.
This means you can space code out for readability without changing how it is parsed.
Apostrophe Comments
An apostrophe starts either a full-line comment or an inline comment.
' full line comment
counter = counter + 1 ' inline comment
Anything after the apostrophe on the same line is ignored.
Block Comments
Block comments start with Rem and end with End Rem.
- The match is case-insensitive.
- Leading and trailing whitespace are ignored when checking for Rem and End Rem.
- A line containing only Rem starts the block comment.
- A line containing only End Rem ends the block comment.
- Everything inside the block is ignored.
- If the file ends before End Rem appears, it is a syntax error.
Rem
this text is ignored
End Rem