# data[].attributes.headline
Get 5 friends (from SAME LAB session) to create your team.

# data[].attributes.subject
Get 5 friends (from SAME LAB session) to create your team.

# data[].attributes.body
1. You may use this platform to call out to your friends if you need a group.  Leave your communication ways in here to let others get to you.
2. If you need to recruit members to get 5, please leave your communication way here to let the interested friend to contact you.

# data[].attributes.body
Does anyone have a spot in their group ? My contact is 017-2668505.

# data[].attributes.body
Does anyone have an extra slot allow me to join? Contact info: 0167912772 (Esmond)

# data[].attributes.body
Hi i am looking for a group to join. My contact number is 011-10437331 (Iffah) thanks

# data[].attributes.body
Hi everyone, im Zaim and im looking for a group to join. My contact is 0176518055

# data[].attributes.body
Hi, My name is So Jin Boon. I would like to find or create a group. Here is my phone number: 016 921 3348. Feel free to WhatsApp me. Thanks.

# data[].attributes.body
Hi, My name is Anish , I looking for group this will be my contact information 0129437273. Feel free to contact me , Never gonna let you down :rickroll: out

# data[].attributes.headline
Looking for a group to join from Lab session 1AL

# data[].attributes.subject
Looking for a group to join from Lab session 1AL

# data[].attributes.body
Hi, I'm Mohammad Tarig. I'm looking for a group to join. Anyone need a member from Lab session 1AL, contact me through email: 1201103326@student.mmu.edu.my.

# data[].attributes.body
Hi, my name is Edward Yap. I want to find a group. This is my phone number: 0132895586. Feel free to WhatsApp me.

# data[].attributes.body
0107925573 (yixuan)

# data[].attributes.headline
Hello, I'm Sulaiman Alomari Contact No. +60167063731 Email: 1201303064@student.mmu.edu.my 

# data[].attributes.subject
Hello, I'm Sulaiman Alomari Contact No. +60167063731 Email: 1201303064@student.mmu.edu.my 

# data[].attributes.body
looking for a group

# data[].attributes.body
Hello, I am looking for a group to join. My contact number is 011-21579978 (Suthan) thanks

# data[].attributes.body
Hye my name is Jobert Guan Bong, im looking for group, whatsapp 0126817109

# data[].attributes.headline
Hello, Im [Ahmed husham],Im looking for a group, If there is a spot hit me up. Contact me on 1211300006@student.mmu.edu.my or my whatsapp +97433881036

# data[].attributes.subject
Hello, Im [Ahmed husham],Im looking for a group, If there is a spot hit me up. Contact me on 1211300006@student.mmu.edu.my or my whatsapp +97433881036

# data[].attributes.body
Hello. We need one last member for our group (1AL). If you want to join us, contact me on 1201103326@student.mmu.edu.my

# data[].attributes.body
We are looking for one last group member to join us.
We are group 6.

# data[].attributes.body
5. Consider the programming languages you have learned, categorized into the four bins: imperative, functional, logic, and Markup/programming hybrid.

1)Imperative / Procedural

Java, JavaScript, Visual BASIC .NET, C++

2) Functional Main
(We never learn any of it)

3)Logic Rule-based (rules are specified in no particular order) Example: Prolog

4)Markup/programming hybrid Markup languages
(We never learn)

# data[].attributes.body
10. What is the disadvantage of having too many features in a language?

If a language has a large number of different constructs, some programmers might not be familiar with all of them. This situation can lead to a misuse of some features and a disuse of others that may be either more elegant or more efficient, or both, than those that are used. If a programming language gets too complex, the readability, write-ability, and cost of supporting the language increase exponentially.

# data[].attributes.body
11. Explain two reasons why pure interpretations is an acceptable implementation method for several recent scripting languages.

It is batch-oriented and not used in critical systems.

# data[].attributes.body
7.      Discuss the methods of implementing the programming languages.

Compilation

o   High-level language (C++) is translated into machine language

o   Create executable file

o   Use: Large commercial applications

Pure Interpretation

o   Converts the source code line-by-line during RUN Time.

o   Original programs are interpreted by another program known as an interpreter (scripts embedded in HTML)

o   Use: Small programs or when efficiency is not an issue

Hybrid Implementation Systems

o   A compromise between compilers and pure interpreters

o   Translates high-level languages into intermediate forms (byte code),  which are then interpreted (Java Virtual Machine)

o   Use: Small and medium systems when efficiency is not the first concern

# data[].attributes.body
Why do you need to use the programming environments? Use an example of programming environment to support your opinion.

Generally, a programming environment mixes hardware and software that allows a developer to build applications. For example, Developers usually work on Codeblock or similar IDEs that connect them with all the features necessary to write and test their code correctly.

# data[].attributes.body
12. Why, in your opinion, do new scripting languages appear more frequently than compiled languages? Explain with example

ans - Yes, because scripting language are often smaller and simpler and focused on more narrow applications, which means their libraries need not be nearly as large. For example, C, C++(compiled language) and PHP, JavaScript (scripting language).

List of the most popular programming languages that will be in demand in 2022.

1. Javascript
..
6. PHP
..
11. C and C++

# data[].attributes.body
7c)      A = A + ( B * ( C ) )

<assign> => <id> = <expr>

=> A = <expr>

=> A = <id> + <expr>

=> A = A + <expr>

=> A = A + (<expr>)

=> A = A + (<id> * <expr>)

=> A = A + (B * <expr>)

=> A = A + (B * (<expr>))

=> A = A + (B * (<id>))

=> A = A + (B * (C))

# data[].attributes.headline
Big Brain - Question 7 a) A = A * ( B * ( C + A ) )

# data[].attributes.subject
Big Brain - Question 7 a) A = A * ( B * ( C + A ) )

# data[].attributes.body
<assign> => <id> = <expr>
=> A = <id> * <expr>
=> A = A * (<expr>)
=> A = A * ( <id> * <expr> )
=> A = A * ( B * ( <expr> ) )
=> A = A * ( B * ( <id> + <expr> ) )
=> A = A * ( B * ( C + <id> ) )
=> A = A * ( B * ( C + A ) )

# data[].attributes.body
5. List out all the properties of the following grammar:

<class_head> -> {<modifier>} class <id>

<modifier> -> public | abstract | final

ANS:
Start: <class_head>

Terminal: final, abstract, public, class, { }
Non-Terminal: <class_head>, <id>, <modifier>, <modifier>
Rules: <class_head> -> {<modifier>} class <id>
<modifier> -> public | abstract | final

# data[].attributes.body
1.     Identify the lexemes and tokens from the following programming codes.

# data[].attributes.body
Question 6

Design the grammar (BNF) that accepts the sentences with the mathematical operations: multiplication (*) and addition (+).

1 .<id>-> <char>+<char> | <char>*<num>
<char>-> A | B | C | D
<num>-> 2 | 4

2.<expr>-> <expr><op><expr>
<op>-> +| *
<expr>-> A | B | C | D

3.<term>-> <term><op><term>
<op>-> * | +
<term>-> 1 | 2 | 3 | 4

# data[].attributes.body
7(b) :
<assign> => <id> = <expr>
=> B = <id>*<expr>
=> B = C*(<expr>)
=> B = C*(<id>+<expr>)
=> B = C*(A+<id>*<expr>)
=> B = C*(A+C*<expr>)
=> B = C*(A+C*<id>)
=> B = C*(A+C*B)

# data[].attributes.body
What are the primary tasks of a lexical analyzer?
In short, lexical analyzers find lexemes ( character sequences) and group them into tokens. Additionally, The lexical analyzer is responsible for removing the white spaces and comments from the source program. It corresponds to the error messages with the source program. It helps to identify the tokens. The input characters are read by the lexical analyzer from the source code.

It also helps to identify tokens in the symbol table. Symbol Table is an important data structure created and maintained by the compiler in order to keep track of the semantics of variables i.e. it stores information about the scope and binding information about names, information about instances of various entities such as variables and functions names, classes, objects, etc.

# data[].attributes.body
The grammar accepts all the string x and y. The x can contain multiple x or single x while the y can have multiple y or single y. The examples are xy, xxy, xyy, xxyy and xxxyyy.

# data[].attributes.body
The lexical analyzer works closely with the syntax analyzer. It reads character streams from the source code, checks for legal tokens, and passes the data to the syntax analyzer when it demands. The symbol table can be fetched by parser of the ways they used from time to time. First to remove white space, then extract the lexemes. The pattern of lexeme will tell which token it belongs to. If the token cannot match will generate syntax error. If there is no error, it will pass to parser and process to syntax analyzer.

# data[].attributes.attachment_caption
8.	Prove that the following grammar is ambiguous: 

# data[].attributes.body
If sentence = X*Y*Z
This grammar can generate the sentence(X*Y*Z) with the different parse trees.

# data[].attributes.body
We can only build one parse tree for grammar Q whereas grammar P can generate several parse trees, grammar P is ambiguous while grammar Q is unambiguous. const + const + const, is the sentence that we generated for both grammar Q and grammar P.

# data[].attributes.body
<MD> -> ab | a <MD> b
<MD> = non-terminal
ab = terminal

# data[].attributes.body
BNF
<digit> --> 1|2|3|4|5|6|7|8|9|0
<unsigned_integer> - > <digit> <digit><unsigned_integer>

EBNF: {}, {}*, ( )
<unsigned_integer> => <digit><unsigned_integer>
=> <digit><digit><unsigned_integer>
=> <digit><digit><digit>
=> 123
<digit> --> 1|2|3|4|5|6|7|8|9|0
<unsigned_integer> -> {<digit>}*
OR
<digit> --> 1|2|3|4|5|6|7|8|9|0
<unsigned_integer> -> <digit> {<digit>}

# data[].attributes.body
Q1. Describe the differences between top-down and bottom-up parsers

Top-down parsing (Recursive Descent) is a parsing technique that first looks at the highest level of the parse tree and works down the parse tree by using the rules of grammar while Bottom-up Parsing (shift-reduce) is a parsing technique that first looks at the lowest level of the parse tree and works up the parse tree by using the rules of grammar.

Top-down parsing attempts to find the leftmost derivations for an input string. Bottom-up parsing can be defined as an attempt to reduce the input string to the start symbol of a grammar (reverse of rightmost deriviation).

# data[].attributes.body
Remove left recursion in the following grammar :

A  -> ABD | c | b | a | cBD

X = A

Alpha = BD

Beta 1 = c

Beta 2 = b

Beta 3 = a

Beta 4 = cBD

Replace by :

A -> β 1 A’ | β 2 A’ | … | β n A’
A’ -> α 1 A’ | α 2 A’ | … | α m A’ | ε

After remove :

A -> cA ‘ | bA ‘ | aA ‘ | cBDA ‘

A' -> BDA ‘ | null

# DONE

# data[].attributes.body
1.     Why left-recursive grammar causes problem to recursive-descent parsing?

recursive descent parsing is a top-down parsing technique and top-down parsers cannot handle left recursion when performing the leftmost derivation. top-down parsers will enter an infinite loop due to left recursion.

E.g.: leftmost derivation
grammar : expr -> expr + term | term
term - > A|B|C

expr => expr + term
=> exprt + term + tem
=> ....

# data[].attributes.body
2. In what way are reserved words better than keywords?

A reserved word is a special word of a programming language that cannot be used as a name. As a language design choice, reserved words are better than keywords because the ability to redefine keywords can lead to readability & confusing problems.

# data[].attributes.body
1. What are the design issues for names? Demonstrate with sample codes and output.

1)Design issues for names: Names in c++ are case-sensitive.
Are names case-sensitive?
Names in c++ are case-sensitive. For example in this program, using x instead of X will give different outputs.

error messages:
C:\Users\User\OneDrive\Desktop\Q1.cpp|7|error: 'X' was not declared in this scope|

# data[].attributes.body
2)Are special words, reserved words, or keywords?
Keywords in c++ cannot be a name.
In this program, protected cannot be used as variable names so no output will be shown.

error message:
C:\Users\User\OneDrive\Desktop\Q1.cpp|6|error: expected unqualified-id before 'protected'|
C:\Users\User\OneDrive\Desktop\Q1.cpp|7|error: expected primary-expression before 'protected'|
||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

# data[].attributes.body
3. Describe binding and binding time.
- A binding is an association between an entity and an attribute, such as between a variable and its type or value, or between an operation and a symbol
- Binding time is the time at which a binding takes place.

# data[].attributes.body
6.Decide which of the following identifier names is valid in C++ language. Why?

a) _Student (valid, the first character can be a underscores.)

b) int (invalid, a reserved word cannot be used as an identifier name because there is a reserved meaning.)

c) Student (valid, the first character can be a letter)

d) 123Student (invalid, the first character cannot start with a digit)

e) Student123 (valid, the first character can be a letter and combine with digits).

# data[].attributes.body
4. What are the six attributes of a variable?
Name, Address, Value, Type, Lifetime, Scope

# data[].attributes.body
5. What are the processes took place during binding time?

Language design time -- bind operator symbols to operations (symbol * is bound to multiplication).

Compile time -- bind a variable to a type in C or Java.

Load time -- bind a C or C++ static variable to a memory cell.

Link time -- multiple object codes (machine code files) and libraries are combined into one executable.

Runtime -- bind a non static local variable to a memory cell.

# data[].attributes.body
Q7) Some programming languages are typeless. What are the obvious advantages and

disadvantages of having no types in a language? Demonstrate with sample codes and

output.

The advantage of a typeless language is flexibility; any variable can be used for any type values.

The disadvantage is poor reliability due to the ease with which type errors can be made, coupled with the impossibility of type checking detecting them.

Rexx sample program

1. Add is a function defined to add 2 numbers.

2. In the main program, the values of 5 and 6 is used as parameters to the add function.

3. The exit keyword is used to exit from the main program. This is used to differentiate the main program from the add function.

4. The add function is differentiated with the ‘:’ symbol.

5. The parse statement is used to parse the incoming arguments.

6. Finally, the return statement is used to return the sum of the numeric values.

# data[].attributes.body
Consider the following JavaScript skeletal program, what is the value of x displayed
in function sub1 by using static-scoping and dynamic-scoping rules?
var x;
function sub1() {
document.write("x = " + x + "<br />");
}
function sub2() {
var x;
x = 10;
sub1();
}
x = 5;
sub2();

Ans:

Using static scoping: x=5. The static parent of sub 1 is main where declaration is found. X in sub 1 is ignored as it is not in static ancestry of sub 2.

Using dynamic scoping: x=10. Dynamic scoping is based on calling sequence of subprograms and not spatial relationship to each other. Thus, sub 1 will search its dynamic parent which is sub 2.

# data[].attributes.body
a) a derived from main

b derived from fun1

c derived from fun2

d e f derived from fun3

# data[].attributes.body
Pointer 1 :
b,c,d defined “definition 2” ; (visible)
a defined “definition 1” ; (hidden)
e doesn’t exist.

Pointer 2 :
c, d, e defined “ definition 3”; (visible)
b defined “definition 2”; (hidden)
a defined “definition 1”. (hidden)

Pointer 3:
b, c, d defined “definition 2” ; (visible)
a defined “definition 1” ; (hidden)
e doesn’t exist.

Pointer 4:
a, b, c defined “definition 1”.  (visible)
D and e doesn’t exist.

# data[].attributes.body
https://docs.google.com/document/d/1puGWIKJ1RK5dsSrMFsIqK3oh632W4ib-BaV7k4gOBTE/edit

# data[].attributes.attachment_link.description
Create a new document and edit with others at the same time -- from your computer, phone or tablet. Get stuff done with or without an internet connection. Use Docs to edit Word files. Free from Google.

# data[].attributes.body
https://docs.google.com/document/d/1EEe4iQR45UoYvTWnNCM0wn5ImmwHkF7BkPSFAXd2WNo/edit?usp=sharing

# data[].attributes.attachment_link.description
Create a new document and edit with others at the same time -- from your computer, phone or tablet. Get stuff done with or without an internet connection. Use Docs to edit Word files. Free from Google.

# data[].attributes.body
https://docs.google.com/document/d/1gteiVfVNZ5GrF1TVA_R2o_PWbrfDQreh/edit

# data[].attributes.attachment_link.description
Create a new document and edit with others at the same time -- from your computer, phone or tablet. Get stuff done with or without an internet connection. Use Docs to edit Word files. Free from Google.

# data[].attributes.body
https://docs.google.com/document/d/1MWA17IEiQntt9kqosCfQzer7f7BGeFmIoJ0RFbnWReU/edit

# data[].attributes.attachment_link.description
Create a new document and edit with others at the same time -- from your computer, phone or tablet. Get stuff done with or without an internet connection. Use Docs to edit Word files. Free from Google.

# data[].attributes.body
https://docs.google.com/document/d/1BBGO2Lud2C7eL2PvpMDeAt4wmEXFoEfSv3iW53sFxcE/edit?usp=sharing

# data[].attributes.attachment_link.description
Create a new document and edit with others at the same time -- from your computer, phone or tablet. Get stuff done with or without an internet connection. Use Docs to edit Word files. Free from Google.

# data[].attributes.body
https://docs.google.com/document/d/1Fu_RSPvBsHv-W79Z83ciopji5LH6SA0h/edit?usp=drivesdk&ouid=101488311376627831577&rtpof=true&sd=true