LoginSignup
0
0

いろんな言語のコメントの書き方

Last updated at Posted at 2022-12-14
  • プログラミング言語 (C など)
  • シェル言語 (Shell など)
  • ビルド言語 (GNU Make など)
  • メタビルド言語 (CMake など)
  • マークアップ言語 (HTML など)

を含む様々な言語のコメントの書き方を一覧にしました。

Ada

-- single-line comment

APL

⍝ single-line comment

AsciiDoc

// line comment

////
    block comment
////

[comment]
--
block comment
--

[comment]
block comment

References

  1. AsciiDoctor Docs - Comments

AWK (POSIX.1-2017)

# line comment

B

Bash

Basic

C

// single-line comment
/*
    multi-line comment
*/

C++

// single-line comment
/*
    multi-line comment
*/

C#

// single-line comment
/*
    multi-line comment
*/

CSS

/*
    multi-line comment
*/

D

// single-line comment
/*
    multi-line comment
*/
/+
    nestable multi-line comment
+/
/// single-line documentation comment
/**
    multi-line documentation comment
*/
/++ nestable multi-line documentation comment
+/

DOT

// line comment
/*
    block comment
*/

Reference

  1. Graphviz, DOT Language, https://graphviz.org/doc/info/lang.html.

F#

// line comment
(*
    block comment
*)

Fortran

Fortress

ECMAScript

Erlang

Fish

# single-line comment

Go

// single-line comment
/*
    multi-line comment
*/

Gradle

Groovy か Kotlin のサブセットであるのでそれに従う。

Groovy

// line comment
/*
    block comment
*/

Haskell

-- line comment
{-
    block comment
-}

Haxe

// single-line comment
/**
    multi-line comment
**/

HTML

<!--
    multi-line comment
-->

Io

J

Java

// single-line comment
/*
    multi-line comment
*/

JavaScript

// single-line comment
/*
    multi-line comment
*/

Julia

# single-line comment
#=
    multi-line comment
=#
"single-line documentation comment"
foo(xs::Array) = ...
"""
    multi-line documentation comment
"""
bar(xs::Array) = ...

Kotlin

// single-line comment
/*
    multi-line comment
*/

Lisp

Lua

-- line comment
--[[
    block comment
--]]

他にもブロックコメントの方法があるらしいがよく分かっていない。

GNU Make

# single-line comment

Matlab

% line comment
%{
    block comment
%}

Apache Maven

XML のサブセットなので XML に準ずる。

m4

# line comment

References:

  1. POSIX.1-2017 m4
  2. GNU m4

Nim

# single-line comment
#[
    multi-line comment
]#

Meson

# line comment

References

  1. https://mesonbuild.com/Syntax.html#comments

Ninja

# line comment

OCaml

Pascal

(*
    block comment
*)  
{
    block comment
}  

Perl

# single-line comment
=pod
    multi-line documentation comment
=cut

PowerShell

# single-line comment
<#
    multi-line comment
#>

Protocol Buffer 2

// single-line comment
/*
    multi-line comment
*/

Protocol Buffer 3

// single-line comment
/*
    multi-line comment
*/

Python

# single-line comment
"""
    documentation comment
"""

Q

R

# line comment

Rust

// line comment
/*
    block comment
*/
//! inner line documentation comment
/// outer line documentation comment
/**
    outer block documentation comment
*/

S

Scala

Scheme (R⁵RS)

; single-line comment

Scheme (R⁶RS)

; single-line comment
#; single-line comment
#|
    multi-line comment
|#

Shell (POSIX.1-2017)

# line comment

References

  1. Shell Command Language

SQLite

-- line comment
/*
    block comment
*/

Swift

// line comment
/*
    block comment
*/

TeX

% line comment

TOML

# single-line comment

U

Vala

Wolfram

(*
    multi-line comment
*)

XML

<!--
    multi-line comment
-->

YAML

# line comment
0
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0