This is a collection of notes and references on relevant syntactic variations in different computer languages.

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.

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 { }.

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 { }.

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++

    https://www.cprogramming.com/reference/

C#

ChucK

C-style winged and block comments. No string or character literal syntax. Statements terminated by ;.

CoffeeScript

Block comments with # , winged comments #. Strings with ' or " and can be multiline. Block strings with """ and '''.

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

https://crystal-lang.org/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.

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

Factor

Forthlike, token-oriented language. Winged comment with !. Strings with ". C-style backslash escapes.

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

https://fantom.org/doc/docLang/index

Forth

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.

Guile

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.

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.

JSX

LiveScript

  • Block comments with /* , winged comments #.

  • Strings with ' or " and can be multiline.

  • Block strings with """ and '''.

    Language reference

    http://livescript.net/#overview

mal

Mal is a small pedagogic Lisp with multiple implementations that follow the Make-A-Lisp process.

Standard Lisp model. Strings have C backslashes.

MoonScript

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.

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.

Skew

Winged commends with #. No bloc comments. String lterals with ; or " and C-style backslashes. C-style block syntax.

Language reference

http://skew-lang.org/

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

Vimscript

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.