Ағылшыншамен салыстырыңыз: абзацты басыңыз — түпнұсқа терезеде ашылады. Абзац астындағы EN түймесі оны мәтін ішінде көрсетеді.
Мазмұны
Кіріспе
Компьютерлік кодты машинамен оқылатын түрге түрлендіру
Converting computer code into a machine readable form
Компьютерлік есептеуде кодты жасау – компилятордың процестік тізбегінің бір бөлігі болып табылады және бастапқы кодтың аралық өрнегін мақсатты жүйеде оңай орындалатын формаға (мысалы, машина коды) түрлендіреді. Күрделі компиляторлар әдетте әртүрлі аралық формалар бойынша бірнеше рет өтеді. Бұл көп сатылы процесс кодты оңтайландыру алгоритмдерінің көптеген түрлерін біртіндеп қолдануға немесе бір оңтайландырудың нәтижесі екінші оңтайландырудың аяқталған өңдеуіне байланысты болғандықтан қолданылады. Бұл құрылым бірнеше архитектураны қолдайтын бір компиляторды құруды жеңілдетеді, себебі кодты жасау кезеңдерінің соңғысы ғана (бэкэнд) мақсатты жүйеге қарай өзгереді. (Компиляторды құру туралы толық ақпаратты Compiler бетінен қараңыз.) Кодты жасаушының кірісі әдетте синтаксистік талдау ағашы немесе абстрактілі синтаксистік ағаштан тұрады. Ағаш сызықтық нұсқаулар тізбегіне айналады, әдетте үш адрес коды сияқты аралық тілде. Компиляцияның келесі кезеңдері бағдарламаның өрнегінде маңызды өзгерістер болса, "кодты жасау" деп аталуы мүмкін, болмауы мүмкін. (Мысалы, "тесікше" оңтайландыру кезеңі "кодты жасау" деп аталмайды, бірақ кодты жасаушыға "тесікше" оңтайландыру кезеңін қосу мүмкін.)
In computing, code generation is part of the process chain of a compiler and converts intermediate representation of source code into a form (e. g., machine code) that can be readily executed by the target system. Sophisticated compilers typically perform multiple passes over various intermediate forms. This multi stage process is used because many algorithms for code optimization are easier to apply one at a time, or because the input to one optimization relies on the completed processing performed by another optimization. This organization also facilitates the creation of a single compiler that can target multiple architectures, as only the last of the code generation stages (the backend) needs to change from target to target. (For more information on compiler design, see Compiler.) The input to the code generator typically consists of a parse tree or an abstract syntax tree. The tree is converted into a linear sequence of instructions, usually in an intermediate language such as three address code. Further stages of compilation may or may not be referred to as "code generation", depending on whether they involve a significant change in the representation of the program. (For example, a peephole optimization pass would not likely be called "code generation", although a code generator might incorporate a peephole optimization pass.)
Орындау уақытында кодты құру
Кодты құру орындалу кезінде жүргенде, мысалы, уақытында компиляциялау (JIT) кезінде, бүкіл процестің уақыт және жад тұрғысынан тиімді болуы қажет. Мысалы, егер тұрақты өрнектер интерпретацияланып, орындалу кезінде кодты құру үшін қолданылса, детерминистік емес шекті автомат детерминистік автоматтың орнына көбінесе жасалады, себебі әдетте біріншісі тезірек құрылады және соңғысынан аз жад алады. Тиімділігі төмен кодтар жасалғанымен, JIT кодты құру орындалу кезінде ғана қолжетімді болатын профильдеу ақпаратын пайдалана алады.
When code generation occurs at runtime, as in just in time compilation (JIT), it is important that the entire process be efficient with respect to space and time. For example, when regular expressions are interpreted and used to generate code at runtime, a non deterministic finite state machine is often generated instead of a deterministic one, because usually the former can be created more quickly and occupies less memory space than the latter. Despite its generally generating less efficient code, JIT code generation can take advantage of profiling information that is available only at runtime.
Қарым-қатынас ұғымдары
Бір тілдегі деректерді қабылдап, едәуір өзгеше тілде нәтиже шығарудың негізгі міндеті формалды тіл теориясының негізгі түрлендіру операциялары арқылы түсіндіріледі. Осының салдарынан, бастапқыда компиляторларда қолдану үшін жасалған кейбір техникалар басқа мақсаттарда да пайдаланыла бастады. Мысалы, YACC (Yet Another Compiler Compiler) Backus–Naur пішіміндегі деректерді қабылдап, оны C тіліндегі синтаксистік талдаушыға айналдырады. Ол бастапқыда компилятор үшін синтаксистік талдаушыны автоматты түрде жасау үшін құрастырылған болса да, yacc жиі спецификациялар өзгелген сайын өзгерістерді енгізу қажеттігі туындайтын кодты жазуды автоматтандыру үшін қолданылады. Көптеген интеграцияланған даму орталары (IDE) автоматты бастапқы кодты генерациялаудың әртүрлі формаларын қолдайды, көбінесе компиляторлық код генераторларымен ортақ алгоритмдерді пайдаланады, бірақ көбінесе одан әлдеқайда қарапайым. (Сондай-ақ қараңыз: Бағдарламаны түрлендіру, Деректерді түрлендіру.)
The fundamental task of taking input in one language and producing output in a non trivially different language can be understood in terms of the core transformational operations of formal language theory. Consequently, some techniques that were originally developed for use in compilers have come to be employed in other ways as well. For example, YACC (Yet Another Compiler Compiler) takes input in Backus–Naur form and converts it to a parser in C. Though it was originally created for automatic generation of a parser for a compiler, yacc is also often used to automate writing code that needs to be modified each time specifications are changed. Many integrated development environments (IDEs) support some form of automatic source code generation, often using algorithms in common with compiler code generators, although commonly less complicated. (See also: Program transformation, Data transformation.)
Ойлану
Жалпы, синтаксис және семантикалық талдаушы бастапқы кодтан бағдарламаның құрылымын алуға тырысады, ал код генераторы осы құрылымдық ақпаратты (мысалы, деректер түрлерін) код жасау үшін пайдаланады. Басқаша айтқанда, біріншісі ақпаратты қосады, ал екіншісі ақпараттың бір бөлігін жоғалтады. Осы ақпарат жоғалтудың бір салдары – рефлексия қиынға соғады немесе тіпті мүмкін болмайды. Бұл мәселені шешу үшін код генераторлары орындалуға қажетті кодқа қосымша синтаксистік және семантикалық ақпаратты да қосады.
In general, a syntax and semantic analyzer tries to retrieve the structure of the program from the source code, while a code generator uses this structural information (e. g., data types) to produce code. In other words, the former adds information while the latter loses some of the information. One consequence of this information loss is that reflection becomes difficult or even impossible. To counter this problem, code generators often embed syntactic and semantic information in addition to the code necessary for execution.