Home /UOG — University of Gujrat /Compiler Construction

Compiler Construction BS UOG — University of Gujrat 2024

Compiler Construction BS UOG — University of Gujrat 2024 — page 1

Discussion

Ask a question about this paper, or help someone else with theirs. Answers are emailed to whoever asked.

Your email is only used to send you replies and occasional Ustadni updates. It is never shown publicly.

Log in to post under your name

No questions yet — be the first to ask.

Need Paper? See all →

Need a paper or stuck on a question? Ask here — students reply and you get an email.

Ask about a paper
  • Bushra· 21 hours ago

    BS Islamic Studies, 5th semester, ISL-511 Translation of Holy Quran (3) — Government College University Faisalabad (GCU…

    0 replies Reply →
  • Khadija· 2 days ago

    Civics course code GCCE101

    1 reply Reply →
  • Tasddaq hussain· 2 days ago

    BS 4the semester2025 civics and community engagement past paper According UOs

    0 replies Reply →
  • Humna Khan· 3 days ago

    Bs public administration 1st semester mid term past papers

    0 replies Reply →
  • Rania· 3 days ago

    BS English from uni of Sargodha Functional English, history of old English literature, literary devices and genres,

    0 replies Reply →
Ad

Paper text

UNIVERSITY OF GUJRAT DEPARTMENT OF CS, HAFIZ HAYAT CAMPUS Mid-Term Examination Fall-2024 Course: Compiler Construction Course Code: CS462 Maximum Marks: 25 Program: BSCS Time: 90 Min Name: Roll No: Q No. 01 What is a compiler? Describe the main components of a compiler. (3+5Marks) Q No. 02 Explain the role of syntax analysis and semantic analysis in compiler (05 Marks) construction and why they are important? Q No. 03 Consider the CFG: (05Marks) E -> T | E + T | E - T T -> F | T * F | T / F F -> num | (E) and the input string 3+5*(2-4) Construct a step by step parse tree for the given input string using above stated grammar. Q No. 04 #include using namespace std; int add(int a, int b) { return a + b; } int main() { int num1, num2; cout << "Enter two numbers: "; cin >> num1 >> num2; int result = add(num1, num2); cout << "Sum: " << result << endl; if (result > 0) { cout << "Result is positive." << endl; } else if (result < 0) { cout << "Result is negative." << endl; } else { cout << "Result is zero." << endl; } return 0; } Make pairs of tokens from above stated lines of code by identifying 1. Keywords. 2. Identifiers. 3. Numeric, Boolean and Pointer Literals. 4. String and Character Literals. 5. User-Defined Literals. 6. Operators. 7. Punctuators.