各种语言的注释总结--from wiki

简介:

Comments can be classified by:

  • style (inline/block)
  • parse rules (ignored/interpolated/stored in memory)
  • recursivity (nestable/non-nestable)
  • uses (docstrings/throwaway comments/other)

Inline comments[edit]

Inline comments are generally those that use a newline character to indicate the end of a comment, and an arbitrary delimiter or sequence of tokensto indicate the beginning of a comment.

Examples:

Symbol Languages
C Fortran 77 and earlier; the 'C' must be in column 1 of a line to indicate a comment.
REM::: BASICCOMMAND.COMcmd.exe, batch files
NB. J; from the (historically) common abbreviation Nota bene, the Latin for "note well".
APL; the mnemonic is the glyph (jot overstruck with shoe-down) resembles a desk lamp, and hence "illuminates" the foregoing.
# Bourne shell and other UNIX shellsCobraPerlPythonRubySeed7Windows PowerShellPHPRMaple
% TeXPrologMATLAB,[9] ErlangS-LangVisual Prolog
// ActionScriptC (C99)C++C#DGoJavaJavaScriptObject Pascal (Delphi), Objective-CPHPScalaSASS
' Visual BasicVBScriptRealBasic
! Fortran, Basic Plus, Inform
; AutoHotkeyAutoItLispCommon LispClojureRebolScheme, many assemblers
-- EuphoriaHaskellSQLAdaAppleScriptEiffelLuaVHDLSGML
* COBOL (if fixed-form and * in column 7), PAW, many assemblers, Fortran (if fixed-form and * in column 1)
|| Curl
" Vimscript
\ Forth

Block comments[edit]

Block comments are generally those that use a delimiter to indicate the beginning of a comment, and another delimiter to indicate the end of a comment. In this context, whitespace and newline characters are not counted as delimiters.

Examples:

 

Symbol Languages
¢ ~ ¢# ~ #co ~ cocomment ~comment ALGOL 68
/* */ ActionScript, AutoHotkey, C, C++, C#, D, Go, Java, JavaScript, Objective-C, PHP, PL/I, Scala (can be nested), SASS, SQL, Visual PrologCSS
#cs #ce AutoIt
/+ +/ D (can be nested)
/# #/ Cobra (can be nested)
<# #> Powershell
=begin =cut Perl
=begin =end Ruby
#<tag></code> <code>#</tag> S-Lang
{- -} Haskell (can be nested)
(* *) Object Pascal (Delphi), ML, Mathematica, PascalSeed7ApplescriptOCaml (can be nested), Standard ML (can be nested), Maple, Newspeak
{ } Object Pascal (Delphi), Pascal
|# #| Curl
%{ %} MATLAB[9] (the symbols must be in a separate line)
#| |# LispSchemeRacket (can be nested in all three).
--[[ ]] Lua
" " Smalltalk
(comment ...) Clojure

本文转自二郎三郎博客园博客,原文链接:http://www.cnblogs.com/haore147/p/3606079.html,如需转载请自行联系原作者
相关文章
|
29天前
|
自然语言处理 算法 前端开发
C++与Doxygen:精通代码文档化之道
C++与Doxygen:精通代码文档化之道
49 0
|
1月前
|
存储 开发者 Python
Python常用插件之emoji表情插件的用法
Python常用插件之emoji表情插件的用法
24 0
|
3月前
|
JavaScript 前端开发 Java
小笔记:表 - 各种语言的 CommonMark Markdown解析器 实现
小笔记:表 - 各种语言的 CommonMark Markdown解析器 实现
77 1
|
3月前
doxygen根据代码生成文档
doxygen根据代码生成文档
12 0
|
8月前
|
PHP
PHP - Laravel Blade模板注释 {{-- 注释 --}} 与 <!-- 注释 --> 的区别
PHP - Laravel Blade模板注释 {{-- 注释 --}} 与 <!-- 注释 --> 的区别
63 0
|
7月前
|
Rust 前端开发 编译器
Rust的注释与文档
Rust的注释与文档
37 0
|
8月前
|
JSON 自然语言处理 JavaScript
go 语言实战入门案例之命令行排版词典
go 语言实战入门案例之命令行排版词典
50 0
|
Python
Sphinx+github+ReadtheDocs书写笔记
Sphinx+github+ReadtheDocs书写笔记
175 0
Sphinx+github+ReadtheDocs书写笔记
Markdown 额外语法支持 - GitHub Flavored Markdown
Syntax highlighting 语法突显 下面是一个例子,告诉你如何使用 GitHub 语法突显标记: function fancyAlert(arg) { if(arg) { $.facebox({div:'#foo'}) } } 您也可以简单地将代码缩进四个空格:
100 0
Markdown 额外语法支持 - GitHub Flavored Markdown