Aug 13, 2022Kuina-chan


This is the language specification 10 of Kuin Programming Language, and is about the other syntax.

1Kuin Comment

1.1Multi-line Comment



In Kuin, the part enclosed by "{" and "}" is a multi-line comment, which will be skipped at compile time.
The specification of multi-line comments is shown in Figure 1-1.
  • The part enclosed by "{" and "}" is considered as a single space character at compile time.
  • Multi-line comments can be nested. For example, it can be written as "{{{comment}}}".
  • The "{" and "}" in char literals and []char literals are considered to be characters or strings, not comments.
  • Multi-line comments can be written even in the middle of a line, and can span multiple lines as a comment.
Figure 1-1: Multi-line Comment Specification
Reason For The Design

The notation for using "{" and "}" for multi-line comments comes from Pascal.

The C language comments "/*" and "*/" cannot be nested, so if the commented-out part contained comments, the "*/" in the middle would match and could not be commented out correctly. Therefore, Kuin allows comments to be nested.

1.2Single-line Comment



In Kuin, from the ";" at the beginning of the line to the newline at the end of the line is a single-line comment, which will be skipped at compile time.
The specification of single-line comments is shown in Figure 1-2.
  • A single-line comment cannot start in the middle of a line, and the first character of the line must be a ";" except for whitespace characters.
  • A ";" in a char literal or []char literal is considered a character, not a comment.
  • When multi-line comments, single-line comments, char literals, and []char literals are mixed, the first one to appear takes precedence.
Figure 1-2: Single-line Comment Specification
Reason For The Design

The notation of using ";" for single-line comments comes from the x86 assembler.

The reason for adopting "{", "}", and ";" as symbols for comments was decided by a method of elimination, as it is desirable not to duplicate symbols used in operators.

2Line Splitting

In Kuin, simply breaking a line in the middle of a line will result in a compilation error. If you want to break a line in the middle of the line, write "|" at the beginning of the line immediately after the line break (Figure 2-1).
  1. func f()
  2.   do @g
  3.   |(
  4.   |2 + 3,
  5.   |@a * @b,
  6.   |@h()
  7.   |)
  8. end func
Figure 2-1: Line Splitting
The specification of line splitting is shown in Figure 2-2.
  • If the next character after a newline is "|", except for whitespace, the newline and "|" are assumed to be absent, and it is assumed to be a single whitespace character at compile time.
  • Lines cannot be separated by "|" in character literals and in string literals.
Figure 2-2: Line Splitting Specification
Reason For The Design

In Visual Basic and C macros, when you want to start a new line in the middle of a line, you need to put a specific character at the end of the line, but in Kuin, important information is gathered at the beginning of a line, so I made it so that you can determine if you are starting a new line or not.

1660382427enf