Skip to content

1.6. Trivia#

Syntax#


WHITESPACE = (" " | "\t")+;

END_OF_LINE = "\n" | ("\r" "\n"?);

SINGLE_LINE_COMMENT = "//" (!("\r" "\n"))*;

MULTI_LINE_COMMENT = "/*" (!"*" | "*")* "*/";

SINGLE_LINE_NAT_SPEC_COMMENT = "///" (!("\r" "\n"))*;

MULTI_LINE_NAT_SPEC_COMMENT = "/**" (!"*" | "*")* "*/";

Single Line Comments#

A single-line comment is terminated by any unicode line terminator (LF, VF, FF, CR, NEL, LS or PS) in UTF-8 encoding. The terminator is still part of the source code after the comment, so if it is not an ASCII symbol (these are NEL, LS and PS), it will lead to a parser error.

// This is a single-line comment.

Multi-line Comments#

Comments starting with /* and ending with */ are allowed to range multiple lines:

/*
This is a
multi-line comment.
*/

NatSpec Comments#

Additionally, there is another type of comment called a NatSpec comment. They are written with a triple slash /// or a double asterisk block /**...*/ and they should be used directly above function declarations or statements. It is recommended that Solidity contracts are fully annotated using NatSpec for all public interfaces (everything in the ABI).

/// @author My Team Name
/// @title A simple contract example
contract MyContract {}

Please see the NatSpec Format section for further information.

Note

This section is under construction. You are more than welcome to contribute suggestions to our GitHub repository.