9.1 Programs

本文介绍C#程序由一个或多个源文件(编译单元)组成,源文件是Unicode字符序列。程序编译分三步:将文件从特定字符集和编码方案转换为Unicode字符序列、将Unicode输入字符流转换为标记流、将标记流转换为可执行代码。实现需接受UTF - 8编码的源文件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

9.1 Programs
A C# program consists of one or more source files, known formally as
compilation units (§16.1). A source file is
an ordered sequence of Unicode characters. Source files typically have a
one-to-one correspondence with files in
a file system, but this correspondence is not required.
Conceptually speaking, a program is compiled using three steps:
1. Transformation, which converts a file from a particular character
repertoire and encoding scheme into a
sequence of Unicode characters.
2. Lexical analysis, which translates a stream of Unicode input characters
into a stream of tokens.
3. Syntactic analysis, which translates the stream of tokens into
executable code.
Conforming implementations must accept Unicode source files encoded with
the UTF-8 encoding form (as
defined by the Unicode standard), and transform them into a sequence of
Unicode characters. Implementations
may choose to accept and transform additional character encoding schemes
(such as UTF-16, UTF-32, or non-
Unicode character mappings).
[Note: It is beyond the scope of this standard to define how a file using a
character representation other than
Unicode might be transformed into a sequence of Unicode characters. During
such transformation, however, it is
recommended that the usual line-separating character (or sequence) in the
other character set be translated to the
two-character sequence consisting of the Unicode carriage-return character
followed by Unicode line-feed
character. For the most part this transformation will have no visible
effects; however, it will affect the
interpretation of verbatim string literal tokens (§9.4.4.5). The purpose
of this recommendation is to allow a
verbatim string literal to produce the same character sequence when its
source file is moved between systems that
support differing non-Unicode character sets, in particular, those using
differing character sequences for lineseparation.
end note]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值