0% found this document useful (0 votes)
8 views4 pages

Compiler Project template

This document outlines the rules and syntax for a compiler construction project by Waleed and Zain. It covers various programming concepts including variable declaration, types, arithmetic operations, conditional statements, loops, functions, and classes. Each section provides specific syntax examples and structures for implementing these concepts in a programming language.

Uploaded by

xawofiy968
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views4 pages

Compiler Project template

This document outlines the rules and syntax for a compiler construction project by Waleed and Zain. It covers various programming concepts including variable declaration, types, arithmetic operations, conditional statements, loops, functions, and classes. Each section provides specific syntax examples and structures for implementing these concepts in a programming language.

Uploaded by

xawofiy968
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

COMPILER CONSTRUCTION TEMPLATE

Name: Waleed & Zain


Reg: 222-NUN-0055
Reg: 222-NUN-0056
Sem: BSCS - Fifth
Compiler Construction Project
Write the rules/syntax for the followings
Examples ___________________________________________________________________________________ 3
Variables: ___________________________________________________________________________________ 3
Variable declaration: ________________________________________________________________________ 3
Variable types: _______________________________________________________________________________ 3
Arithmetic and Logical Operations: _______________________________________________________________ 3
Increment/Decrement (Pre & Post): _______________________________________________________________ 3
Input/outut __________________________________________________________________________________ 3
Conditional Statements: ________________________________________________________________________ 3
Body of conditions: _________________________________________________________________________ 3
Switch(val) __________________________________________________________________________________3
Arrays ______________________________________________________________________________________ 4
Loops: ______________________________________________________________________________________ 4
Functions: ___________________________________________________________________________________ 4
Body of function ____________________________________________________________________________ 4
Functions calling ___________________________________________________________________________ 4
Classes: _____________________________________________________________________________________ 4
Examples
Variables:
Variable declaration:
Variable name starts with symbol ‘#’
define #*variable_name* as *type*
Variable types:
• Integers (Numbers)
• Real (for Decimal)
• Text (String)
• boolean (true/false
Arithmetic and Logical Operations:
Arithmetic Operators: +, -, *, /
Logical Operators: And, Or, Not
Increment/Decrement (Pre & Post):
Pre-Increment: ++#variable_name

Input/oututp

Input: read #variable_name


Output: display “message”, display #variable_name

Conditional Statements:
If: when(condition)
Else: otherwise
Body of conditions:
when (#variable_name > 10) {
// body
} otherwise {

// else body
}

Switch Statement

evalute #variable_name {
case 1:
// body
case 2:
// body
default:
// default body
}

Arrays :

Syntax: set array #array_name [size] of <type>


Example: set array #numbers [10] of integer

Loops:
For Loop:
repeat (start=0; start < 10; start++) {
// body
}

While Loop:
as_long_as (#variable_name < 10) {
// body
}

Functions:
Declaration:
function <type> functionName() {
// body
}

Calling a Function:
invoke functionName();

Classes:
Syntax: create class <className> {}
Example: create class Car {}

You might also like