This is a collection of notes and references on relevant syntactic variations in different computer languages.
- General references
Standard Model
Standard Model (SM) describes a large group of languages with Algol-like syntax and the following traits:
-
Double-quoted string literals.
-
Single-quoted character literals with exactly one character in them.
There may or may not be a statement terminator/separator.
C Model
C model adds to SM
-
C-style backslash escapes for string delimiters.
-
/\* \*/ block comments, no nesting.
-
// winged comments.
-
Statements terminated by ;.
-
Block begin and end are { }.
Winged comments were introduced in C99 from C++ and were not present in older C.
Lisp Model
-
Double-quoted string literals.
-
A tick operator, always following a space.
-
Winged comments with semicolons
-
No statement terminator.
-
May or may not have block-comment syntax.
Ada
SM plus a tick operator; tick always follows and precedes an identifier with no whitespace intervening.
-
Winged comments with --.
-
Statements terminated by ;.
-
Block begin-end are :begin" and "end".
B
-
Double-quoted strings.
-
Character literals may have more than one character, the value is packed into a machine word; see "putchar('*n*n');".
-
Winged comments with //.
-
/\* \*/ block comments, nesting unspecified.
-
No C backslashes yet. Has a pre-C escape convention using an asterisk.
-
Statements terminated by ;.
Block begin/end are C-like { }.
- User’s Manual
BCPL
-
Single quoted strings.
-
No backslashing.
-
No syntactic use of double quotes.
-
Winged comments, no block comments.
-
No statement terminator.
Block begin/end are C-like { }.
- Reference manual
C, C++, Objective-C, Yacc, Lex, Java
Straight C model.
-
Yacc and Lex have %% sections with different syntax.
-
Java string and character literals may contain Unicode.
-
C preprocessor is applied.
- Syntax reference for C and C++
C#
-
C model
-
Verbatim strings start with @" and end with " and may span multiple lines.
ChucK
C-style winged and block comments. No string or character literal syntax. Statements terminated by ;.
- Specification
CoffeeScript
Block comments with # , winged comments #. Strings with ' or " and can be multiline. Block strings with """ and '''.
- Language reference
Crystal
winged comments. No block comments.
C-style string and character literals with escapes. Regexp literals with bare / syntax. No statement terminator. Blocks with do/end.
- Language reference
Dylan
-
C-style block and winged comments.
-
String and character literals as in C, with backslash escapes.
-
Statements terminated by ;.
-
Idiosyncratic ALGOL-68-like block syntax.
- Reference manual
elisp
Lisp model. No block comments.
Elixir
No block comments, winged comments with #. Strings with ' or ", multiline strings with """ or '''. No statement terminator.
There are regexp literals, led with ~r/.
Elvish
-
Winged comments with #
-
No block comments.
-
Backslash line continuation
-
String literals with ' or ".
-
Strings may contain newlines.
-
C-style backslash escapes
- Reference
Factor
Forthlike, token-oriented language. Winged comment with !. Strings with ". C-style backslash escapes.
- Factor handbook
Fantom
C-like comments with /* / and //. There’s an additional synax * for documentation comments.
String literals with " and C backslashes. Triple-quote string literals with """. There’s an idiosyncratic third string literal syntax for DSLs. C-like block syntax with { }. No statement terminator.
- Language documentation
Forth
-
Block comments with ( )
-
Winged comments with \\
-
The Forth word s" pushes its token argument on the stack as a literal.
Groovy
Like Java with some additions: inline string literals with both " and ', Python style mutiline strings delimited by """ and '''. It also has "slashy strings" which behave like bare regexp literals. And dollar-slashy strings, a multiline version of same.
Groovy allows a hashbang comment at start of text.
- Syntax reference
Guile
Lisp model with C backslashing.
Haxe
C-style block and winged commments. Strings may have " or ' as delimiter. Regexp literals with ~// syntax. C backslashes are interpreted. Statements terminated by ;. C-style begin/end with {}.
Hy
Lisp model. Newlines are allowed in strings.
Io
Winged comments with //. Block comments with /* */. Winged comments with # are also allowed. Strings with "". C-style backslashes.
- Reference
JavaScript, ActionScript, es6, Typescript
C model comments and inline strings. Adds single-quoted strings, regular-expression literals with bare // syntax. Statements terminated by ;. C-style begin/end with {}.
Typescript is a syntactic superset of JavaScript. ActionScript is a JavaScript dialect for the Flash macromedia player.
- es6 Standard
- Typescript handbook
-
http://www.typescriptlang.org/docs/handbook/basic-types.html
- Regexp literals
JSX
- Reference
LiveScript
-
Block comments with /* , winged comments #.
-
Strings with ' or " and can be multiline.
-
Block strings with """ and '''.
- Language reference
Logo
-
Winged comments begin with ;. There are no block comments.
-
String literals begin with " and are terminated by whitespace.
-
No statement terminator.
- Reference manual
mal
Mal is a small pedagogic Lisp with multiple implementations that follow the Make-A-Lisp process.
Standard Lisp model. Strings have C backslashes.
- Repository
MoonScript
- Reference
Pkl
String literals with double quotes. Winged comments with ///. No statement terminator.
Pony
String literals with double quotes. Winged comments with //. No statement terminator.
Like Python, module comments are multistring literals.
PowerShell
-
Winged comments with , block commenrs with < #>
-
Strings with "".
-
Idiosyncratic escape syntax with backtick.
-
C-like blocks with { }.
-
No statement terminator.
- PowerShell syntax
PostScript
PostScript is a stack-based language with graphics capabilities. It is usually used for defining documents that will render to printer or screen. PostScript files are typically generated and most PostScript generators put a comment starting with !PS-Adobe on the first line.
Winged-comment leader us %. No block comments.
Racket
Lisp-model syntax. C backslash escapes.
Has | | block comments which nest. .
Groovy allows a hashbang comment at start of text.
Scala
C-model comments, string/character literals, and escapes. C-style block syntax. No statement terminator.
- Specification
Skew
Winged commends with #. No bloc comments. String lterals with ; or " and C-style backslashes. C-style block syntax.
- Language reference
Smalltalk
The GNU implementation of Smalltalk-80.
Winged comments with //. No block comments. An initial hashbang line is allowed, but loccount doesn’t know what "gst" means.
Visual Basic
-
Winged coments with '.
-
No block comments.
-
String literals with ""
-
C-style backslashes.
-
No statement terminator.
Vimscript
-
String literals with " at start of line.
-
String literals with ' or ".
-
C backslash escapes.
WebAssembly Macros
Standard WebAssembly text format .wat is s-expr based. .wast is the same syntax but denotes spec tests files (multiple modules, asserts, etc). .wam refers to WebAssembly Macro language (https://github.com/kanaka/wam) and also uses the same syntax.
Winged comments with ;. Block comments with (; ;). Strings are ".
XC
C-model syntax.
- Specification
Yorick
C-model comments, string/character literals, and escapes. C-style block syntax.