Docsity

COMPILERS CONSTRUCTION, Assignments of Theory of Automata

Toggle sidebar
bg1
COMSATS University Islamabad, Wah
Campus
Theory Assignment 1
Department of:
COMPUTER
SCIENCE
Class/Program: BS(7-A,C,D)
Due
Date: 29 Sep 2022 11:59 AM
Subject: Compiler Construction Instructor: Muhammad Nadeem
Note: copying will lead to ZERO
This is hand written assignment.
You are required to write your Name and Registration Number on top of each
paper of your assignment.
You need to submit hard and soft form of assignment. Both must be
submitted in time.
Also Scan assignment using any scanner tool (like CAMSCANNER), create a
pdf , and upload to server (CUONLINE), prior to due time.
No email will be accepted, except the students having registration issue.
Q1. Java Script is a scripting and powerful language for client side
scripting. It has different type of tokens, with unique properties.
Different tokens with associated properties are given below. You need to
write a Regular Expression for each type of token.
Token Type Property
Variable Name Start with _ and then there can be a repetition of Letter,
Number and _ .
Number Contain one or more digits
Float Start with one or more digits , then there is . followed by
one or more digits.
Power Number Start with one or more digits followed by e followed by
one or more digits. (e.g 123e67)
Negative
Power
Start with one or more digits followed by e followed by โ€“
and followed by one or more digits. (e.g 123e-67)
String Start with โ€œ and end with โ€ and in between there can be
number, float, power number, negative power
Comparison > or < or = or == or != or >= or <=
pf3
pf4

Partial preview of the text

Download COMPILERS CONSTRUCTION and more Assignments Theory of Automata in PDF only on Docsity!

COMSATS University Islamabad, Wah

Campus

Theory Assignment 1 Department of: COMPUTER SCIENCE Class/Program: BS(7-A,C,D) Due Date: 29 Sep 2022 11:59 AM Subject: Compiler Construction Instructor: Muhammad Nadeem Note: copying will lead to ZERO This is hand written assignment. You are required to write your Name and Registration Number on top of each paper of your assignment. You need to submit hard and soft form of assignment. Both must be submitted in time. Also Scan assignment using any scanner tool (like CAMSCANNER), create a pdf , and upload to server (CUONLINE), prior to due time. No email will be accepted, except the students having registration issue. Q1. Java Script is a scripting and powerful language for client side scripting. It has different type of tokens, with unique properties. Different tokens with associated properties are given below. You need to write a Regular Expression for each type of token. Token Type Property Variable Name Start with _ and then there can be a repetition of Letter, Number and _. Number Contain one or more digits Float Start with one or more digits , then there is. followed by one or more digits. Power Number Start with one or more digits followed by e followed by one or more digits. (e.g 123e67 ) Negative Power Start with one or more digits followed by e followed by โ€“ and followed by one or more digits. (e.g 123e-67 ) String Start with โ€œ and end with โ€ and in between there can be number, float, power number, negative power Comparison > or < or = or == or != or >= or <=

Operator (Here or is used as choice between these operators) Change operator ++ or - - or +=Number (Here or is choice, while Number is a RE expressing Number) Keywords goto In instanceof Static finally arguments public Do else Const Function class* return let* Catch Eval For if This try Separators + or โ€“ or! or != or == or >> or << or % or / or # or & or space or \n or \t Comment Start with // followed by Variable Name and Digits and ends with //

// check if number is less than 1 // else { console.log("The number is not a prime number."); }