language_definition
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
language_definition [2012/02/26 15:54] – [Constants] mhwang | language_definition [2012/03/17 08:56] (current) – [新语言与C/Pascal/Java的比较] marong | ||
---|---|---|---|
Line 2: | Line 2: | ||
* [[contributed_functions|Contributed functions]] | * [[contributed_functions|Contributed functions]] | ||
* [[the_eight_queens_solver|The eight queens solver]] | * [[the_eight_queens_solver|The eight queens solver]] | ||
- | * calculator of pi | + | * [[pi_calculator|calculator of pi]] |
====== 新语言与C/ | ====== 新语言与C/ | ||
Line 15: | Line 15: | ||
| 变量声明 | | 变量声明 | ||
| 多维数组 | | 多维数组 | ||
+ | | 注释 | ||
+ | |||
+ | 改进的建议(这学期不适用) | ||
+ | |||
+ | 1. 允许全局变量 | ||
+ | |||
+ | 2. 函数,变量,类型有独立的名字空间 | ||
+ | |||
+ | 3. 变量将强制初始化 | ||
+ | |||
+ | 4. 变量可以在块中间声明 | ||
+ | |||
+ | 5. 去掉break和continue | ||
+ | |||
+ | 6. 去掉逗号表达式 | ||
+ | |||
+ | ---by marong | ||
====== Lexical Aspects ====== | ====== Lexical Aspects ====== | ||
A //token// can be a keyword, an identifier, a integer constant, a character constant, or a string constant. | A //token// can be a keyword, an identifier, a integer constant, a character constant, or a string constant. | ||
Tokens are separated by whitespaces and comments. | Tokens are separated by whitespaces and comments. | ||
- | An // | + | An // |
- | Case is significant in identifiers. | + | Note that (i) identifiers cannot start with underscores, |
//Line terminators// | //Line terminators// | ||
Line 29: | Line 46: | ||
There are two types of comments: line comments and block comments. | There are two types of comments: line comments and block comments. | ||
- | //Line comments// starts with two slashes ''/ | + | //Line comments// starts with two slashes ''/ |
- | //Block comments// starts with a ''/ | + | //Block comments// starts with a ''/ |
=====Constants===== | =====Constants===== | ||
Line 37: | Line 54: | ||
There are no negative integer constants. | There are no negative integer constants. | ||
- | A //character constant// is one printable character, or escape sequences that represents one character, surrounded by a pair of single quotes ''''' | + | A //character constant// is one printable character |
- | A //string constant// is a sequence of zero or more printable characters, spaces, or escape sequences, surrounded by a pair of double quotes ''"'' | + | A //string constant// is a sequence of zero or more printable characters, spaces, or escape sequences, surrounded by a pair of double quotes ''"'' |
Escape sequences begins with a backslash '' | Escape sequences begins with a backslash '' | ||
Line 48: | Line 65: | ||
| '' | | '' | ||
| '' | | '' | ||
- | | '' | + | | '' |
| '' | | '' | ||
Line 57: | Line 74: | ||
| '';'' | | '';'' | ||
| '','' | | '','' | ||
- | | ''< | + | | ''< |
| '' | | '' | ||
Line 64: | Line 81: | ||
* '' | * '' | ||
* '' | * '' | ||
- | * '' | ||
- | * '' | ||
* '' | * '' | ||
* '' | * '' |
language_definition.1330271682.txt.gz · Last modified: 2012/02/26 15:54 by mhwang