Skip to content

ECMAScript翻译指南(2021.5)

Hoarfroster edited this page May 18, 2021 · 2 revisions

简介

ECMAScript 是 JavaScript 语言规范,由 ECMA TC39 负责制定,每年 6 月份发布一个新版本。当前及所有历史版本可以在这里看到

要查看最新的 ECMAScript 规范,则要访问 TC39 官网:https://tc39.es/ecma262/。这里包含最近一版年度规范和自该年度规范发布以来进入第 4 阶段(已经完成)的提案。最新规范又分单页版多页版

ECMAScript 规范的可编辑文本托管在 Github 上面,使用的是一种名叫 Ecmarkup 的纯文本格式。Ecmarkup 是一种 HTML 和 Markdown 的混合体,提供了一个以纯文本形式编写 ECMAScript 规范,并将其处理为遵循规范编辑约定的可交互HTML文档的框架和工具集。Ecmarkup 集成了 GrammarkdownEcmarkdown,前者用于定义语法,后者用于编写算法步骤。

早期的 ECMAScript 规范使用 Word 编写,最初的 Ecmarkup 源文本是使用自动转换工具由 ECMAScript 2015 Word 文档转换而来。

各部分译法参考

序号 英文 中文 单词数 理由
Introduction 前言 1353 位于正文之前,而且完整介绍了每个历史版本;符合“前言”的惯例
1 Scope 范围 12 定义了本规范所要涉及的范围
2 Conformance 符合性 303 即实现是否符合规范,一般说符合性测试
3 Normative References 规范性参考 83 其实就是其他参考性规范;相应地,non-normative xx翻译为“非规范性的xx”
4 Overview 概述 3661 语言起源及宿主、实现,还有术语定义
5 Notational Conventions 表示法约定 5301 包含语法、记法文法、算法相关的表示法
6 ECMAScript Data Types and Values ECMAScript数据类型和值 14882 执行环境
7 Abstract Operations 抽象操作 9113
8 Syntax-Directed Operations 语法导向操作 9229
9 Executable Code and Execution Contexts 可执行代码与执行上下文 12776
10 Ordinary and Exotic Objects Behaviours 普通与异质对象的行为 16995
11 ECMAScript Language: Source Code ECMAScript语言:源代码 2103 ECMAScript编程语言,包括语法编码和所有语言特性的执行语义
12 ECMAScript Language: Lexical Grammar ECMAScript语言:词法文法 7984
13 ECMAScript Language: Expressions ECMAScript语言:表达式 12262
14 ECMAScript Language: Statements and Declarations ECMAScript语言:语句和声明 8289
15 ECMAScript Language: Functions and Classes ECMAScript语言:函数和类 8924
16 ECMAScript Language: Scripts and Modules ECMAScript语言:脚本和模块 9525
17 Error Handling and Language Extensions 错误处理和语言扩展 703
18 ECMAScript Standard Built-in Objects ECMAScript标准内置对象 968 ECMAScript标准库,包括ECMAScript程序执行时可用的所有标准对象的定义
19 The Global Object 全局对象 4764
20 Fundamental Objects 基本对象 8218
21 Numbers and Dates 数值和日期 15877
22 Text Processing 文本处理 22851
23 Indexed Collections 索引存取集合 19633
24 Keyed Collections 键存取集合 5836
25 Structured Data 结构化数据 12190
26 Managing Memory 管理内存 1175
27 Control Abstraction Objects 控制抽象对象 14163
28 Reflection 反射 1193
29 Memory Model 内存模型 4487 基于SharedArrayBuffer的内存访问一致性模型和Atomics对象的方法
A Grammar Summary 文法小结 4138
B Additional ECMAScript Features for Web Browsers 针对浏览器的ECMAScript特性 7551
C The Strict Mode of ECMAScript ECMAScript严格模式 600
D Host Layering Points 宿主分层点 166
E Corrections and Clarifications in ECMAScript 2015 with Possible Compatibility Impact ECMAScript 2015?? 447
F Additions and Changes That Introduce Incompatibilities with Prior Editions 之前版本引入不兼容性的增补与修改 1822
G Colophon 特别说明 126
H Bibliography 参考文献 192
I Copyright & Software License 版权与软件许可 550

参考术语

序号 英文 中文 解释 例句
clause 规范文本的划分,类似章节
4 host environment 宿主环境 ECMAScript程序的运行环境,比如浏览器、Node.js;规范本身没有定义获取外部数据和输出计算结果的能力,因此宿主需要提供环境特有的对象,包括属性和函数,供ECMAScript程序访问和调用。宿主经常是外部的规范,如HTML规范,因此宿主定义的机能经常会在外部规范中进一步定义。 A host environment is a particular choice of definition for all host-defined facilities. A host environment typically includes objects or functions which allow obtaining input and providing output as host-defined properties of the global object./宿主环境是包含所有宿主定义机能的一种特定选择。宿主环境通常包含对象和函数等全局对象的宿主定义属性,用于获取输入和提供输出。
facility 机能 规范指称的特性、能力或机制 A scripting language is a programming language that is used to manipulate, customize, and automate the facilities of an existing system./脚本语言是用于操作、定制和自动化已有系统机能的编程语言。
host hook 宿主挂钩 全部或部分由外部来源定义的抽象操作
defers 推迟 推迟某些机能的定义
deferrals
indexed collections 索引存取集合
keyed collections 键存取集合
implementation-approximated 实现近似的 由外部资源全部或部分定义的功能,但规范给出了建议的理想行为
implementation-defined 实现定义的 由本规范的外部资源全部或部分定义的功能
host-defined 宿主定义的 由本规范的外部资源全部或部分定义的功能(同上)
primitive value 原始值 第6条定义的Undefined、Null、Boolean、BigInt、Symbol或String值语言实现直接在最底层表示的数据(datum)
ordinary object 普通对象 基本内部方法(essential internal method)都具有默认行为的对象
exotic object 异质对象 一个或多个基本内部方法不具有默认行为的对象(一个对象要么是普通对象,要么是异质对象)
essential internal method 基本内部方法 普通对象11个内部方法,函数对象2个内部方法(在JavaScript中,可以通过Reflect API访问。——译者注)
standard object 标准对象 语义由本规范定义的对象
build-in object 内置对象 ECMAScript实现规定并提供的对象
property 属性 对象的组成部分,关联一个键(字符串或符号)和一个值
attribute 特性 用于定义属性性质的内部值
own property 自有属性 对象直接包含的属性
inherited property 继承属性 非自有属性,是对象原型(自有或继承)的属性
5 production 产生式
alternative 代换式
left-hand side 产生式左端
right-hand side 产生式右端
chain production 链式产生式 产生式右端是一个非终结符和零或多个终结符
goal symbol 目标符 以唯一非终结符开始的定义
terminator (symbol) 终结符
nonterminator (symbol) 非终结符
Input element
tokens These tokens are the reserved words, identifiers, literals, and punctuators of the ECMAScript language.
supplemental grammar 补充文法
early error 先验错误 对代码求值前,必须先行验证并报告的错误;发现先验错误,意味着不再求值
syntactic grammer 语法文法 :
lexical and RegExp grammer 词法正则文法 ::
number string grammer 数值字符串文法 :::
syntactic acceptability 语法接受度
“Let x be someValue” “令x为someValue” These aliases are reference-like in that both x and someValue refer to the same underlying data and modifications to either are visible to both.
abstract operations 抽象操作 In order to facilitate their use in multiple parts of this specification, some algorithms, called abstract operations, are named and written in parameterized functional form so that they may be referenced by name from within other algorithms.
syntax-directed operation 语法导向操作
runtime semantics 运行时语义 Algorithms which specify semantics that must be called at runtime are called runtime semantics.
normal completion 正常完成
abrupt completion 硬性完成
12 offending token 反常标记

Section 5: Notational Conventions(规范性约定)

表示法约定

  • A lexical gramma r for ECMAScript is given in clause 12 . Input elements other than white space and comments form the terminal symbols for the syntactic grammar for ECMAScript and are called ECMAScript tokens . These tokens are the reserved words, identifiers, literals, and punctuators of the ECMAScript language.
  • A RegExp grammar for ECMAScript is given in 22.2.1.
  • Productions of the lexical and RegExp grammars are distinguished by having two colons “::” ****as separating punctuation. The lexical and RegExp grammars share some productions.
  • The numeric string grammar appears in 7.1.4.1.
  • Productions of the numeric string grammar are distinguished by having three colons “:::” as (separating) punctuation.
  • The syntactic grammar for ECMAScript is given in clauses 13 through 16. This grammar has ECMAScript tokens defined by the lexical grammar as its terminal symbols (5.1.2).
  • Productions of the syntactic grammar are distinguished by having just one colon “:” as punctuation.