# 5.1.2 The Lexical and RegExp Grammars

ECMAScript的*词法文法（lexical）*&#x5728;规范[条款11](https://github.com/js-geek/ecmascript-language-specification-cn/tree/8255e51ad8526c3a1dcf79b6c70215a896ad1301/manuscript/11_ecmascript_language_lexical_grammar/README.md)中给出。该文法使用遵守[条款10.1](https://github.com/js-geek/ecmascript-language-specification-cn/tree/8255e51ad8526c3a1dcf79b6c70215a896ad1301/manuscript/10_scmascript_language_source_code/10_1_source_text.md)定义的*SourceCharacter*的Unicode编码点（code point）作为终结符号。该文法定义了一组产生式，起始于目标符号（goal symbol）*InputElementDiv*，*InputElementTemplateTail*，或*InputElementRegExp*，或*InputElementRegExpOrTemplateTail*，它们描述了代码点序列如何被转换成输入元素序列。 and

除空白符和注释外的输入元素，组成ECMAScript的句法（syntactic grammar）的终结符，被称为ECMAScrpit的记号（tokens）。这些记号是ECMAScript语言的保留字，标示符，字面量和标点符号。此外，断行符（line terminator）虽然不被认为是记号，但也是输入元素流（stream）的一部分，会引导自动分号插入（[automatic semicolon insertion](https://github.com/js-geek/ecmascript-language-specification-cn/tree/8255e51ad8526c3a1dcf79b6c70215a896ad1301/manuscript/11_ecmascript_language_lexical_grammar/11_9_automatic_semicolon_insertion.md)（[11.9](https://github.com/js-geek/ecmascript-language-specification-cn/tree/8255e51ad8526c3a1dcf79b6c70215a896ad1301/manuscript/11_ecmascript_language_lexical_grammar/11_9_automatic_semicolon_insertion.md)））的过程。简单的空白和单行注释会被删除，不会显示在句法的输入元素流中。一个*MultiLineComment*（即/\*...\*/形式的注释，无论它是否跨越了多行），如果没有包含断行符，同样会被删除，但如果包含了一个或多个断行符，则会被一个单独的断行符替换，成为句法的输入元素流的一部分。

ECMAScript的*RegExp文法*在[21.2.1](https://github.com/js-geek/ecmascript-language-specification-cn/tree/8255e51ad8526c3a1dcf79b6c70215a896ad1301/manuscript/21_text_processing/21_2_regexp_objects.md)中定义。该文法有*SourceCharacter*定义的代码点作为自己的终结符号。它定义了一组产生式，起始于目标符号*Pattern*，它描述了代码点序列如何被转换成正则表达式模式。

两个冒号“::”作为分隔符来区分词法和正则表达式文法的产生式。词法和正则表达式文法共享某些产生式。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://js-geek.gitbook.io/ecmascript-language-specification-cn/5-notational-conventions/5.1-syntactic-and-lexical-grammars/5.1.2-the-lexical-and-regexp-grammars.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
