与空格码点一样,换行符码点用于提高源文本的可读性,并将 token (不可分割的词法单位) 彼此分开。然而,与空格码点不同,换行符对文法(grammar)的语法的行为有一定的影响。一般来说,换行符可能发生在任何两个 token 之间,但是有一些地方被文法的语法禁止。换行符也会影响自动分号插入的过程 (11.9)。换行符不能出现在任何 token 中,除了 StringLiteral、Template 或 TemplateSubstitutionTail。 换行符不能出现在字符串标记中,除非作为 LineContinuation 的一部分。

    Like white space code points, line terminator code points are used to improve source text readability and to separate tokens (indivisible lexical units) from each other. However, unlike white space code points, line terminators have some influence over the behaviour of the syntactic grammar. In general, line terminators may occur between any two tokens, but there are a few places where they are forbidden by the syntactic grammar. Line terminators also affect the process of automatic semicolon insertion (11.9). A line terminator cannot occur within any token except a StringLiteral, Template, or TemplateSubstitutionTail. and line terminators cannot occur within a StringLiteral token except as part of a LineContinuation.

    换行符可以发生在多行注释中,但不能发生在单行注释中。

    A line terminator can occur within a MultiLineComment but cannot occur within a SingleLineComment.

    换行符被包含在正则表达式中由 \s 类匹配的空白码点的集合中。

    Line terminators are included in the set of white space code points that are matched by the \s class in regular expressions.

    表 33 列出了 ECMAScript 换行符码点。

    The ECMAScript line terminator code points are listed in Table 33.

    Table 33: Line Terminator Code Points(表 33:换行符码点)

    Code Point Unicode Name Abbreviation
    U+000A LINE FEED (LF)
    进纸
    U+000D CARRIAGE RETURN (CR)
    U+2028 LINE SEPARATOR
    线分隔符
    U+2029 PARAGRAPH SEPARATOR
    参数分隔符

    只有表 33 中的 Unicode 码点被视为换行符。其他新行或断行 Unicode 代码点不被视为换行符,但如果它们符合表 32 中列出的要求,则被视为空白。序列 通常用作换行符。为了报告行号,它应被视为一个单一的 SourceCharacter。

    Only the Unicode code points in Table 33 are treated as line terminators. Other new line or line breaking Unicode code points are not treated as line terminators but are treated as white space if they meet the requirements listed in Table 32. The sequence is commonly used as a line terminator. It should be considered a single SourceCharacter for the purpose of reporting line numbers.

    Syntax
    LineTerminator ::




    LineTerminatorSequence ::

    [lookahead ≠ ]