C/C++ Front End Compiler

本文深入探讨了C/C++编译器的前端部分,包括模板解析、组件处理、语法转换和错误诊断等关键步骤,揭示了从源代码到中间表示的复杂过程。

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

 

C/C++ Front End Compiler

更多精彩内容请访问:http://www.interstron.ru/eng/text.asp?id=1934

Front End Compiler

The C++ compiler front end is rightfully regarded as the core of C++ oriented tools and systems. This most important component performs lexical, syntax and semantic analysis of the program source.

Having performed complete analysis of a program source unit, the front end finally generates the so-called intermediate representation (IR) of the program. The IR is formed on the basis of structures created and filled by the front end while processing the source text. The totality of all these structures contains sufficient information about the original program source .

The variety of tasks related to design and analysis of C++ programs is really great. Issuing of executable files is not the only aim of source processing and in many cases - not the most important one. Still we need as much information about the original program as possible to fulfil any of these tasks. The IR just provides such information and thus due to its configuration it can serve as an universal interface for various development tools. The scheme is shown here

As for traditional compilation, executable code generators finalizing it are the clients of intermediate representation as well as other components.

The Intermediate Representation

Three major components of the intermediate representation (IR) correspond to three categories of C++ entities.

The Program Tree represents the general structure of a program source including program blocks (name spaces, functions and compound statements), declarations, operators, etc.

The Symbol Table includes complete information on all named entities declared in the program: classes, functions, variables, templates, types and so on. The table stores a number of semantic attributes of each entity. The whole set of such attributes provides the complete description of this entity. The symbol table is shown as a hierarchy of local tables each corresponding to a definite area of the source program (class, function, block, name space and so on).

The Type Table - we need this component to support the C++ advanced type system, its possibility to create user types of any complexity and numerous type transformation rules. The type table stores each type in a single entity regardless of the number of references to this type in the program source. Such an approach enables high effectiveness of table access operations (type search, type comparison and so on).

Entities of IR (tree nodes, symbol table elements) include attributes binding an entity to the point of its definition in the source text.

Algorithms supporting program access to the IR are implemented as a separate library, independent of the compiler (in such a case the front end shares this library with other clients).

Features of Interstron's C++ Compiler Front End

  • The front end implements the C++ language of the ISO/IEC 14882:1998 international standard with minor limitations. Its degree of accordance with the standard corresponds to that of the most famous C++ implementations (Microsoft, IBM) and even outdoes them in some aspects (e.g. class template partial specialization, partial ordering of function templates).
  • The intermediate representation generated by the compiler keeps in structured form all the valuable data extracted from the program source, even the comments.
  • The front end is designed as a portable program. On the one hand its source is written in ANSI C / C++ and may be compiled and linked with some well-known tool such as IBM Visual Age C++, Miscrosoft Visual C++, GNU C++. On the other hand its operability was tested for a variety of machines and operating systems including IBM PCs with Windows NT, OS/2, Windows 95/98, FreeBSD, SPARC work stations with Solaris operating system and Sun 3/60 with SunOS.
  • The front end is a completely localized program which makes it possible to display all the compiler's diagnostic messages in any language and not only in English as it is on default. It also allows to use for programming any identificators compliant to ISO/IEC 14882:1998, not only ones traditionally based on English.
  • The front end is a completely original program including no third parties' software or similar freeware systems (like the GNU compiler).
  • The package includes the C++ standard library which provides an extensible framework and contains components for: language support, diagnostics, general utilities, strings, locales, containers, iterators, algorithms, numerics and input/output - as defined in the ISO/IEC 14882:1998 standard.
JSC "Interstron" 1991-2008.
All rights reserved
Russia, Moscow, Dmitrovskoe shosse, 1/1
e-mail: about@interstron.ru
web: www.interstron.ru
Telephone: +7 495 976-83-51
FAX: +7 495 977-60-23
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值