Cs602 java programming fall2016 باقي المنهج

Page 1

Dr. Mabroka A. M.

CS802: Compliers

Spring 2017

symbol table management‫ ادارة جدول الرموز‬ ‫ لتخزين معلومات عن بنية البرنامج‬Compiler ‫هو عبارة عن هيكلية بيانات يستخدمها املترجم‬

ً ‫ التي يتم استخدامها الحقا‬،‫ يتم تجميع هذه املعلومات من قبل مراحل التحليل للمترجم‬.‫املصدر‬

.‫من قبل مراحل التركيب للحصول على الشفرة النهائية‬  Symbol Tables Symbol tables are data structures that are used by compilers to hold information about source-program constructs. The information is collected incrementally by the analysis phases of a compiler and used by the synthesis phases to generate the target code. Entries in the symbol table contain information about an identifier such as its character string (or lexeme) , its type, its position in storage, and any other relevant information. Symbol tables typically need to support multiple declarations of the same identifier within a program. That is the scope of a declaration is the portion of a program to which the declaration applies. We shall implement scopes by setting up a separate symbol table for each scope. A program block with declarations will have its own symbol table with an entry for each declaration in the block. This approach also works for other constructs that set up scopes; for example, a class would have its own table, with an entry for each field and method.

ً ُ ‫) التي تمثل اسم املتغيرة تخزن في‬lexeme( ‫ سلسلة الرموز‬،lexical analyzer ‫ خالل مرحلة املاسح‬:‫مثال‬ Compiler‫ و يتم اضافة معلومات عنها الى الجدول خالل املراحل القادمة من مراحل ال‬.‫جدول الرموز‬ ‫ في‬،position ‫) و موقع تخزينها‬....،‫ متغيرة‬،‫ اسم روتين‬،‫ و مهمتها (اسم مصفوفة‬،type ‫مثل نوعها‬ ُ ‫ تستخدم هذه املعلومات لتوليد الشفرة املناسبة لتخزين و‬code generation ‫مرحلة توليد الشفرة‬ .‫عنونة هذه املتغيرة‬ lexical ‫ العالقة بين جدول الرموز و‬ .‫ ذات الش ئ‬lexeme‫العمليتان الرئيسيتان اللتان تخصان جدول الرموز هما ادراج و استرجاع ال‬ .‫ املنسقة معه‬token‫ يتم تخزين ال‬،‫ في جدول الرموز‬lexeme‫عندما ُيخزن ال‬

36


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.