What is the semicolon in C++?

The semicolon is a terminal, a token that terminates something. What exactly it terminates depends on the context.


The semicolon is a punctuator, see 2.13 §1

The lexical representation of C++ programs includes a number of preprocessing tokens which are used in the syntax of the preprocessor or are converted into tokens for operators and punctuators


Semicolon is a statement terminator.


It is part of the syntax and therein element of several statements. In EBNF:

<do-statement>
    ::= 'do' <statement> 'while' '(' <expression> ')' ';'

<goto-statement>
    ::= 'goto' <label> ';'

<for-statement>
    ::= 'for' '(' <for-initialization> ';' <for-control> ';' <for-iteration> ')' <statement>

<expression-statement>
    ::= <expression> ';'

<return-statement>
    ::= 'return' <expression> ';'

This list is not complete. Please see my comment.

Tags:

C++