On the simplest level, a program
is a sequence of tokens delimited by separators. A token is the smallest
meaningful unit of text in a program. A separator is either a blank or a
comment. Strictly speaking, it is not always necessary to place a separator
between two tokens; for example, the code fragment
Size:=20;Price:=10;
is perfectly legal. Convention and
readability, however, dictate that we write this as
Size := 20;
Price := 10;
Tokens are categorized as special symbols, identifiers, reserved words, directives, numerals, labels, and character strings. A separator can be part of a token only if the token is a character string. Adjacent identifiers, reserved words, numerals, and labels must have one or more separators between them.
关于最简单的语法级别,程序就是一个标记序列,这些标记以分隔符为界。标记是程序文本中最小的有意义的单位。分隔符可以是一个空格,也可以是注释。严格地说,不总是有必要在两个标记之间置分隔符;例如,代码段
Size:=20;Price:=10;
是完全合法的。而从书写习惯和代码易读等方面考虑,一般会写成
Size := 20;
Price := 10;
标记可以分为特殊符号、标识符、保留字、指示字、数字、标号以及字符串等若干类别。分隔符可以作为标记的组成部分,当且仅当标记是一个字符串时。相邻的标识符、保留字、数字以及标号等,其二者之间必须有一个或多个分隔符。