Proposal in Principles of Programming Language: Politeknikong Unibersidad NG Pilipinas
Proposal in Principles of Programming Language: Politeknikong Unibersidad NG Pilipinas
WARM
Proposal in Principles of
Programming Language
Submitted by:
Wesley Florentino
Arjel Joseph Aya-ay
Ryan Matthew Castillejo
Mariz Genelyn Jose
BSCS 2-4
Introduction
Description
II.
11 Syntactical Design
1. Character set
A Character set is a defined list of uppercase and lowercase alphabets,
digits, punctuation, and a few miscellaneous symbols that will be used in the
program.
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
a
b
c
d
e
f
g
uppercase letter a
uppercase letter b
uppercase letter c
uppercase letter d
uppercase letter e
uppercase letter f
uppercase letter g
uppercase letter h
uppercase letter i
uppercase letter j
uppercase letter k
uppercase letter l
uppercase letter m
uppercase letter n
uppercase letter o
uppercase letter p
uppercase letter q
uppercase letter r
uppercase letter s
uppercase letter t
uppercase letter u
uppercase letter v
uppercase letter w
uppercase letter x
uppercase letter y
uppercase letter z
lowercase letter a
lowercase letter b
lowercase letter c
lowercase letter d
lowercase letter e
lowercase letter f
lowercase letter g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
0
1
2
3
4
5
6
7
8
9
!
"
}
lowercase letter h
lowercase letter i
lowercase letter j
lowercase letter k
lowercase letter l
lowercase letter m
lowercase letter n
lowercase letter o
lowercase letter p
lowercase letter q
lowercase letter r
lowercase letter s
lowercase letter t
lowercase letter u
lowercase letter v
lowercase letter w
lowercase letter x
lowercase letter y
lowercase letter z
zero
one
two
three
four
five
six
seven
eight
nine
Space
Exclamation point
quotation mark
right curly bracket
_
%
&
{
(
)
*
+
,
.
/
:
|
<
=
>
?
[
\
]
low line
percent sign
ampersand
left curly bracket
left parenthesis
right parenthesis
asterisk
plus sign
comma
hyphen-minus
full stop
solidus
colon
vertical line
less-than sign
equals sign
greater-than sign
question mark
left square bracket
reverse solidus
right square bracket
Valid Identifiers
Example
COUNTER
test123
The_File_executes
Letters, Digit,
Underscore
Letters
Start
q1
q0
Digits,and
Symbols,
Digits
special
Reserved
symbols words
q2
Digits and special
symbols
Special symbols
q3
case
do
for
break
continue
float
int
return
while
char
double
switch
default
Operator/s
Arithmetic
operator
+, -,
Assignment
operator
Logical operator
| | , && , !
Increment/
decrement
operator
++ , --
Conditional
operator
Relational
operator
*, /, %, **
?:
Description
{ }
( )
Braces
Parenthesis calling
function,
subexpression
grouping
[ ]
Brackets, array
access
Semicolon
Comma
Dot
6. Blank or spaces
;
,
.
Definition
Definition
Symbol
Definition
/* */
Multi-line comment
Example:
/* This is sample program
program is running
warm programming. */
10. Expressions
Precedence order
When two operators share an operand the operator with the higher
precedence goes first. For example, 1 + 2 * 3 is treated as 1 + (2 * 3), whereas 1
* 2 + 3 is treated as (1 * 2) + 3 since multiplication has a higher precedence than
addition.
Associativity
When an expression has two operators with the same precedence, the
expression is evaluated according to its associativity. For example x = y = z =
17 is treated as x = (y = (z = 17)), leaving all three variables with the value
17, since the = operator has right-to-left associativity (and an assignment
statement evaluates to the value on the right hand side). On the other hand, 72 /
2 / 3 is treated as (72 / 2) / 3 since the / operator has left-to-right
associativity.
When operators of equal precedence appear in the same expression, a
rule must govern which is evaluated first. All binary operators except for the
assignment operators are evaluated from left to right; assignment operators are
evaluated right to left.
Operator Precedence
Precedence
Postfix
expr++ expr--
Prefix
++expr --expr!
multiplicative
* / %
additive
+ -
relational
equality
== !=
logical AND
&&
logical OR
||
Ternary
? :
assignment
= += -= *= /=
11. Statement
Assignment Statement
This statement changes the value of the variable on the left side of the
equals sign to the value of the expression on the right-hand side.
The variable is often just specified by a variable name, but there are also
expressions that specify variables.
Example:
int x = 5.
char initial = a.
float y = 10.05.
Compound Statement
These statements are groups of statements enclosed in curly braces ({ }).
They can be used wherever a single statement may be used.
Input Statement
Example:
read(%d,&x ).
Output statement
Example:
write(Hello World).
Selection statement
These statements perform a test; they then execute one section of code if
the test evaluates to true (nonzero). They may execute another section of
code if the test evaluates to false.
if statement
Example:
if(x == y){
write(This statement is true).
}
switch statement
Example:
do-while loop
Example:
do{
write(This statement has been writeed).
x = x + 1.
}while(x<=5).
while loop
Example:
while(x==5){
x++.
write( Live your life).
}
for loop
Example:
for(int i = 0. i < 10. i++){
write(I am a programmer).
}
Jump Statement
These statements transfer control unconditionally
continue
break
Example:
switch(Menu){
case 1: write(case 1).
case 2:{
write(case 2).
break..
}
}
return
addfunction(int x){
x = x + y.
return x.
}
10