You are on page 1of 8

International Conference on Contemporary Issues in IT in OIC Member Countries

U: A Computer Programming Language in Urdu

A.U.Khan, Kashif Ayyub and Hafiz Farooq Khan

Department of Computer Science, COMSATS Institute of Information Technology, Wah., Pakistan. email: auk@cuonline.net.pk

Abstract This paper presents the design and implementation issues of a computer programming language U, having the Urdu-like dialect in contrast to English-like dialect used by mostly available computer programming languages. An account of basic data types supported by U like (integer), (real/float) and (char) is presented. Arithmetic, relational, logical and bit-wise operators of U are presented and there functionality is described. Selection statements of U and and iterative statements such as and are described. The grammar of U language and details of the built-in library functions provided by U is also presented.

Keywords: Urdu, Urdu Computing, Urdu programming, Computer Programming

1. INTRODUCTION

It is the age of Information Technology and the benefits from the Information Technology (IT) revolution cannot be reaped unless masses use it, which is not possible unless computing is possible in a language that is understood by the masses[4]. Major spoken languages of Pakistan are:

Punjabi, Sariaki, Sindhi, Pashto, Urdu, Balochi, Hindko and Brahui. Of these, only Urdu, Sindhi, and Pashto have a standardized alphabet and for rest of the languages, there are a few written works available. However, the alphabets of Pashto, Urdu and Sindhi, the three major languages of the Pakistan, are fully represented in Unicode [3]. According to the Article 251(1) of the constitution: “The National Language of Pakistan is Urdu and arrangements shall be made for its being used as official and other purposes within fifteen years from the commencing day”. For the purpose the National Language Authority (NLA) was constituted, which has proposed the standards for Urdu letters, Urdu Code Page and Urdu

Keyboards[7].

Most of the work under the umbrella of Urdu computing addresses the problems like standardization and development of coding in Urdu [6][7], desktop publishing, Text-to-Speech Systems, English-to-Urdu Translation Systems, etc. but no conceivable work can be found to develop programming tools for Urdu which can be used to create other applications[3]. The U programming language has been developed to provide a programming tool in Urdu, keeping in mind that Urdu is the National Language of the Pakistan and the most of the population can read and write in Urdu and that the Nations like Japan, China, Turkey, etc. are providing the education in their native languages.

2. THE U PROGRAMMING LANGUAGE

Like other computer programming languages, U provides all those facilities which are mandatory to develop useful programs. For the purpose, the syntax of U has been designed as close as possible to the C programming language. However, certain complications arise when writing programs in U due to its right-to-left scripting nature. For example, expressions in U are to be written and evaluated from right-to-left so, the expression has the meaning that is subtracted from whereas in case of left-to-right scripting languages like English, it is interpreted as is subtracted from . Similarly, the prefix in Urdu is English postfix and postfix is to be treated as prefix. The design of U is alike the design of C programming language and its grammar is

International Conference on Contemporary Issues in IT in OIC Member Countries very much similar to C grammar and is attached as annex-I . The table 1 shows the reserved keywords of U and there C equivalent:

Table 1: Reserved Words of U and there C Equivalent

(union)

(if)

(asm)

 

(for)

(struct)

 

(case)

(extern)

 

(goto)

 

(continue)

 

!" (static)

(while)

 

#" $ (sizeof)

%

&' (break)

 

(

) (char)

*+ ,) (float)

- (auto)

.$ (register)

 

(double)

(do)

 

(volatile)

/ 0 1 (enum)

 

20

3 (long)

4 (void)

 

" 4 (signed)

" 4 5 (unsigned)

6$+ (typedef)

7" (short)

 

2

8" (int)

2, $" (const)

 

97

" (switch)

:; (return)

 

(else)

<

<

(default)

     

2.1 Data types

U is a typed language and facilitates to declare 2 8" (integer), *+ ,) and (float/real), and ( )(character) data types. Table-2 shows the U’s declarators and data types that can be defined through them.

Table 2 : Table Showing U’s Data Type Declarators

Declarator

Data type

Meanings

2

8"

integer

Declares an integer

7" or 2 8" 7"

16-bit integer

Declares a short integer

20 3 or 2 8" 20 3

32-bit integer

Declares a long integer

*+ ,)

32-bit float

Declares a float

or *+ ,)

64-bit float

Declares a double

(

)

unicode character

Declares a character

In order to incorporate the user defined data types, the keyword has been provided. For example, the following program fragment declares a structure and depicts its usage:

>=! -

@=! - 2 ?"

A

 

A

D

A

FG E @=! - C0

-

A: H = 7 / C0 - E = 7 / C0

-

D

2.2

Assignment and Arithmetic Operators The U supports various types of arithmetic, and assignment operators which are shown in the

table-3.

Table 3: Table Showing Various Operators Supported By U

Op.

Example

Meanings

+

Adds and

-

Subtracts from

*

Multiplies I and

/

Divides by

-

Negates

%

!

Gives the remainder when ! is divided by

=

"

Assigns value of to

"

#

"

Add 2 to

=-

"

Subtracts from

"

#

"

Multiply by 2

"

"

Divides by i.e is equivalent to "

"J

"J

Calculates I J K and stores back result in K

++

Increment by 1 and use it

 

Use old value of and then increment it by 1

Decrement by 1 and use it

 

--

Use old value of and then decrement it by 1

International Conference on Contemporary Issues in IT in OIC Member Countries

2.3 Logical and Relational Operators

The language also provides logical operators like or && for “and”, L or |$ for “or” and M & and ! for “not”. Similarly, the U also provides relational operators which are shown in the Table-4 along with their meanings.

Table 4: Table Showing The Relational Operators

Op

meanings

 

examples

>

Less than

% , is less than

<

greater than

& , is greater than

=>

Less than or equal to

"% , is less or equal to

=<

greater than or equal to

! "& , is greater or equal to !

==

equal to

"" ,

is equal to

<>

not equal to

&% , is not equal to

2.4 Arrays U also supports arrays and the following program fragment declares a one dimensional array

of integers and initializes its elements to 0:

D APFGO NI 2 ?" D SIHHAFGRIAGEIQ AGEPIO Similarly, the following program fragment declares three
D
APFGO NI 2 ?"
D
SIHHAFGRIAGEIQ
AGEPIO
Similarly, the following program fragment declares three matrices , and and then
calculates the product of matrices and and stores the resultant product into matrix :
A
NPTOPTOINPTOPTOKNPTOPTO , ,)
AUNVNW 2 ?"
D
D

>SWHHATRWAGEWQ AG E SVHH ATRVAGEVQ SUHH AT RUAGEUQ

APVOPUOKXPUOPWO EH

BA E PVOPWOI D

2.5 Control Statements U provides control statements like to complement C’s “if”, < @ in contrast to

else” statement and < @ < @ in place of “if-else if- else” statement. The syntax of various forms of is listed as under:

“if -

SYZ 1Q U [ -[

SYZ 1Q

 

SYZ 1Q U [ -[

U

[ -[

 

<

SYZ 1Q <

 

U

[ -[<

U

[ -[ [< SYZ 1Q <

[ -[ [<

 

U

<

U [ -[<

for the C’s equivalent of “for” statement, and having the syntax:

S< A YZ 1 A< Q

U [ -[

for the pre-condition “while” loop having the syntax of the form:

SYZ 1Q U [ -[

The statement @ is the post-condition loop that tests the condition at the end of the body of the loop and having the syntax:

U [ -[ SYZ 1Q

International Conference on Contemporary Issues in IT in OIC Member Countries

The 97 " is the equivalent of C’s switch statement and its syntax is :

 

>

F[U

D

F[6+ [2, $"

\[U

D

\[6+ [2, $"

 

U[U

D

U[6+ [2, $"

U [ -[< D< B

2.6 Bit wise Logical Operators U also provides bit-wise logical operators which are listed in table 5:

Table 5: Table Showing Bit-Wise Operators Of U

Op.

Meanings bit wise AND bit wise OR bit wise NOT

Example I ' " $ " ( "

&

|

~

2.7 Functions

Like other programming languages, U also provides built-in mathematical functions and also allows programmers to define, their own functions. Table VI shows some of the built in functions and the following program fragment declares two functions, one returning an integer value and the other returning no value and there usage in a the program:

SV 2 ?"Q] " 2 ?"

> AVXV :;

B S 4QV ^ ; 4

> AS`Ub a 5 - V ;`Q&?_ SQV ; AFG E K 2 ?"

>

B

ASKQ] " E I

D

ASQV ^ ;

D

Table 6: Some Mathematical Functions of U

(sin)

(cos)

c (tan)

c SdefQ

+ SghdQ

+ SdeghdQ

i (asin)

i (acos)

ci (atan)

ci SdefQ

+i SghdQ

+i SdeghdQ

i

(sinh)

i (cosh)

i c (tanh)

i c SdefQ

i

+ SghdQ

i

+ SdeghdQ

j (sqrt)

_ (log)

&+ (exp)

a" (abs)

k

   

2.7 I/O Functions Simple I/O functions

for input have also been provided and the

development of rest of the I/O functions is underway.

3. IMPLEMENTATION

Most of the Operating Systems now a days support Unicode [2]. However, implementation for the plain old DOS is also possible through the UNS (Urdu National Support) [1]. For the realization of U, we have used the MS Windows XP which supports the Unicode. In order to test the idea, a prototype U parser and a U to C translator have been developed i.e. the U code is translated to C and then is compiled through a designated C compiler that supports unicode. In future, we are planning the U to also support the computer programming in Pashto and Sindhi.

l8 for output and lm;

To provide the editing facilities in Urdu, an editor namely UrduPad has also been developed. An integrated environment for U is also under development. Further, the U has been designed in

International Conference on Contemporary Issues in IT in OIC Member Countries such a way that a person who has learnt U programming language can easily switch to the C programming language with a very little effort The following is a sample program written in U.

SQ V ;

> v @ sl lm; u 1 *q t 7 / o q V q
>
v @ sl lm; u 1 *q t 7 / o q V q V q Vi " l !r sq s lm; !r/ *q p "i " V ; oL nb
bn sl _ 8 t 7 / 2q *q w "i "
As. & Vi " !r/[*q[w "i " 2 ?"
At 7 / u 1 *, ,)
APFGOV ( )
AS !r/ @*q @w "i "Q lm;
AG E t 7 /
SHHVi " A !r/ [*q [w "i " R Vi " AFEVi "Q
AS` x !r/ *q p "i "`Q l?_
>
AS` x V q Vi "`Q l?_
ASV Q lm;
AS` x u 1 s. & `Q l?_
ASu 1 s. & Q lm;
ASu 1 n s. & Q E
A
H t 7 / E t 7 /
ASu 1 n s. & Q EH t 7 / sl ? &?_ & s$0 ; 3 W " Xb
bX
B
ASt 7 / ` E t 7 / 2q *q w "i " v `Q l?_
B

4. CONCLUSION

Like other programming languages, U can be used as a Urdu programming tool to develop applications, an instructional tool to teach the concepts of computer programming to the masses who do not know English but have the knowledge of Urdu reading and writing, and to the students of lower classes where the medium of instruction is Urdu.

5. REFERENCES

[1] UNS Code Page for DOS [2] Unicode Consortium website at http://unicode.org [3] Abdul-Majid Bhurgri, “Enabling Pakistani Languages Through Unicode”, Microsoft Corporation white paper at http://download.microsoft.com/download/1/4/2/142aef9f-1a74-

4a24-b1f4-782d48d41a6d/PakLang.pdf

[4] M. Afzal and S. Hussain, ”Urdu Computing Standards: Development of Urdu Zabta Takhti (UZT) 1.01”, Proceeding of INMIC2001, organized by IEEE and LUMS, Lahore, December 28-30, 2001, pp:216-222. [5] M. Afzal and S. Hussain, ”Urdu Computing Standards: Urdu Zabta Takhti (UZT) 1.01”, Proceedings of INMIC2001, organized by IEEE and LUMS, Lahore, December 28-30, 2001,

pp:223-228.

[6] K. Zia, “Standard Code Table for Urdu”, http://www.cicc.or.jp/english/hyoujyunka/mlit4/7-

[7]

10Pakistan/Pakistan1.html

National Language Authority web site:

http://www.nla.gov.pk

International Conference on Contemporary Issues in IT in OIC Member Countries The Grammar of U

Annex-I

o @]ç o @ 0 X o @ ç (union) (for) (extern) !" (static) %
o @]ç
o @ 0 X o @ ç
(union)
(for)
(extern)
!" (static)
% &' (break)
- (auto)
(if) (asm)
(struct)
y (goto)
(while)
(case)
(continue)
#" $ (sizeof)
o @ 0 b o @ ç
o @ 0 J o @ ç
( # @?+
( ) (char) *+ ,) (float)
o @ 0
.$ (register)
(double)
o @]ç S 6$+@ " Q
(do) (volatile) / 0 1 (enum)
20 3 (long)
" 4 5 (unsigned)
2 8" (int)
:; (return)
4 (void) " 4 (signed)
3 A.
6$+ (typedef)
7" (short)
o @â! r
2, $" (const) 97 " (switch)
o
@ 0HH
< (else)
< (default)
o @ 0 @@
o
@]ç #" 4@ÉL
Do
o @]ç #" $
S 6$+@ " Q #" $
Szgg{|}~h}f@h
ÄÅhgg{e}Q o @2, "
Sh ÄÅhgg{e}Q o
Szgg{|}~h}f@h ÄÅhgg{e}Q o @2, "
! " # $%&'
3 # D BC
n
Ü H é è
#> 5EF;9
o @ Ç"
o @2, " 2" 4 @2, " o @ÉL
o @â
P
o O o
@â! r
! " # # $ $%&'
S
# êë @o Q o
@â! r
S # êë@o Q V
@6$+@t
EÑÑ ERR EÖ
EÜ Eá Eb En E@ EH E
V í o @â! r
HHo
( # ) *+,-
@@o
@â! r
@â! r
o @ ,a " @ 0
o @ Ç" D o x o @ ,a " @ 0
" 5G F'9
, $"
) ! ( ) /%0' .
V
o @ ,a "@
o @ ,a "@ àà o @ ,a " @ 0
) ! ( ) /%0' 1+2
o @â ä"
" H I
t! q@# 1
) # DL,JK
o @â ä" ÜÜ o @ ,a "@
o @2, "
()3 4 5 &6
N
# êë@o
o
@2, "
o @ãå
o @ãå à o @â ä"
M ) &8N
4 789
o
()3
o @
( # # %&O
o @ Ö o @ãå
1+2
o @â
2, $"@* å)
2, $"@2 8"
2, $"@( )
2, $"@*, ,)
2, $"@t ,ë
o @â Ü o @
:3 ) # 5,92,9
o @*, r/
o @*, r/ EE o @â
o @*, r/ ÑR o @â
M ) ) # ) $%&O &8N
Y
5 à ì äî
) # ) % ;<
o @* , "
o @* , " R o @*, r/
o @* , " Ñ o @*, r/
o @* , " ER o @*, r/
o @* , " EÑ o @*, r/
# ! ( # # $%&O $ P
! r @2 8" 2, $" @p
!
r @2 8" 2, $"@ïl
!
r @2 8" 2, $"@ï1
ñ9 / / @*q@( )ó
= ># %&'
o @ r
o @ r RR o @ , "
o @ r ÑÑ o @ , "
( " ) ( # # $%&O Q2 LG
!4 @t 4@sq@ òî
2, $" @p
!4
R ! # G2E 2 V+
F
\
T
û
ù ú
õ
TU ,S
ö ô
# 4 /;
o @ ç
! # G2E 2
(# ) ( # # $%&O WX
G
G
F
\
T
û
ù
ú õ ö ô
o @ ç H o @ r
o @ ç @ o @ r
"3)# ) ( # 4 /9,?
2, $"@ïl
!4 @ïl

International Conference on Contemporary Issues in IT in OIC Member Countries

(# ) ! # G2E 2 WX

(= (# \+,N V,%K @ wZØ@Æ ^ ` Q ( ) *Z q s M " ( )@â

G

F

\ T û ù ú õ

S( )

 

(

)@*î

= ( " ) ( # # $%&O WY

 
 

G

!4 @ï1 !4 @ï1

 

# # " # _ F9 DU

2, $"@ï1

   

S´z†h´h°@gfzfh~h}fQ U @ ê 1

 

!4 @ï1

Sh ÄÅhgg{e}@gfzfh~h}fQ U @o

 

Sde~Äe©}°@gfzfh~h}fQ U @9q "

= ( " ) ! # G2E 2 WY

Sgh´hdf{e}@gfzfh~h}fQ U @* 7

G

F

\ T û ù ú

õ ö ô

 

S{fhÅzf{e}@gfzfh~h}fQ U @ ?/

 

z

d ° h ¢

©~Ä@gfzfh~h}fQ U @ &'

S

 

£

§

ß ®

S°hd´zÅzf{e}@gfzfh~h}fQ U @*/ 4

 
 

#

! 3>> EF;9 $ P

) ` ) # # " # _ F9 51 a&Y2

 

! r @2L 3 ! r @* " 4 5

 

U

D t! q@# 1

 

! r @* " 4 5 ! r @2L 3

 

U

D o @2, $" î

 

U

D o

3

! 3>> EF;9 & ,FZ

 
 

©

# # " # _ F9

 

3

!

3>> EF;9 $C [

 

A

o

 

´

¨

( " 3 # # " # _ F9 ]U,

 

B

# êë @*q@U >

 

(= (# ( # # $%&O \,N

 

ñ9 / / @*q@(

# # " # ) # DL,JK U _ F9

 
 

U

(= (# :3 ( ]F<,< U \+,N

 

# êë@*q@U

(

)

U

/ /@*q@( )

9

 

(

)

) (# # # " # _ F9 9 b&I2 S{¢@gfzfh~h}fQ U @

(= (# \+,N

Sg {fd @gfzfh~h}fQ U

@97 "

 

@ wZØ@Æ ^ Q ( ) *Z q s M " ( )@â S( )

> # # " # _ F9 ,c2

 

(

)@*î

U

S o Q

 

U

o U

S o Q

( :3 ( \+,N

( )@t

#(= # # " # _ F9 ]b&'

" ) ( :3 ( \+,N VG L

x

à à à ± à U

à W à V à à à ` à ñ

>) # ! ( # # $%&O %F%N

2, $"@â Ç4

o ) @* " 4 ! r @*, ,)

U

S o Q 97 "

# # # # " # _ F9 512,P<

U

U

@y l

U @

9 / / @*q@ !4 o ) @* " 4 ! r @*, ,)

 

 

= ) # # " # _ F9 B&d

> (# ) ( # # $%&O 5,-

 

U

S o Q É

/ /@*q@

9

!4 9 / /@*q@ !4

 
 

9

/ /@*q@ !4

 

# # " # _ F9 e2,XG

# # N &

 

A

S o Q É

U y l

h 4

#"

9 / /@*q@

!4

> # # " # _ F9 f2,9

4

ß

#"

9 / /@*q@

!4

U S o A o A o Z ! @ Q

 

!

D

 

> # ) R Fg2E&92 f2,9

 

H

@

 

U @o

 

U

@* 4

! # :3 (

]F<,< U G2E 2

 
 

!4

 

h3" # # " # _ F9 iI aj

 

9 / /@*q@ !4

U @% &'

 

!4

U

 

U

@:;

>) # ! 3>> EF;9 %F%N

¢

 

` # # " # _ F9 BC,9

   

A

% &'

( # 3 # # " # _ F9 51

# ! (= (# :3 ( ]F<,< U \+,N V,%K

A

 

(

)@t

9 / /@*q@( )@t

#3 # # " # _ F9 kl2+

( )@t ,ë A o :;
(
)@t ,ë
A
o
:;

International Conference on Contemporary Issues in IT in OIC Member Countries

! # # # " # _ F9 e

o @2, $" E t! q@# 1

A

t! q@# 1 y

() # # # " # _ F9 < I 2 o 4

( # # $%&O Sde}°{f{e}z´@h ÄÅhgg{e}Q o @ Ç"

() rC, < % ;<

() # FI 2

B

# êë@o 4 > 2, $"@t

*

# êë@o 4 V $+ @o 4

4

o

2, $"@t

*

L r/@*q@2 4 ìL / @*, r/

() # ) # DL,JK FI 2

4

o

() ( > H Om2 FI 2

o 4 # êë @o 4

6$+@ " V $+ @o 4

() # ) # DL,JK < I 2 o Z ! @*/ 4

Z ! @*/ 4 N # êë @*/ 4

o

# () # Fg2E&92 < I 2

 

Z ! */

o

4

 

# ! () ( > rC, < q U pC1 oL

Sz©feQ q

() # < I 2

SÅh|{gfhÅQ .$

V

@* 4

Sgfzf{dQ !"

P

o @2, $" O*/ 4

Sh fhÅ}Q *

" H I I 2

# ( > nOm G2

@ "@t

ìL /@º q ìL /@*/ L 1

V

V

@*/ L 1

V

>3 (# > # sC,;< U $

ìL /@6$+ @28Ç" 2, $" o ) @* 4 t! q@# 1 V $+ @o
ìL /@6$+ @28Ç"
2, $"
o ) @* 4 t! q@# 1 V $+ @o 4
* >3 (# ` o ) @* 4 " ) # " H I G2
*
>3 (# `
o ) @* 4
" ) # " H I G2 VG L
U
@9q "
Sf Äh°h¢@}z~hQ V @6$+
Sd zÅQ ( )
Sg eÅfQ 7"
S{}fQ 2 8"
S´e}|Q 2L 3
Sg{|}h°Q * " 4
S©}g{|}h°Q * " 4 5
S¢´ezfQ *, ,)
S°e©†´hQ
S§ee´hz}Q * å)
Sæe{°Q â 4
# ) R Fg2E&92
o
E
B
# êë@o Z ! > E
# ) R ) # DL,JK Fg2E&92
o
o
# êë@o Z !
B
# êë@o Z ! >
# > " H I nOm
t!
q@# 1
) ` # # ( > rC, < nOm $P-
t! q@# 1 º q @â! q
# > VE''U D 'Y
Dt! q@# 1

V @*/ L 1

nS !4 à ( )Q S @ à ( )Q

() q U 5EF U s o #" 4@*î D( )@â [ à v à
() q U 5EF U
s
o
#" 4@*î
D( )@â
[
à
v à â à ¿ à ø à K à
D
!4
3" ( > rC, < < C1 Y
ô
à
ö
à ¿
à
\
à
F
à
G
B
# êë @*/ L 1 > t! q@# 1 */ L 1
3 (#3 # t2, 2
P O S Q B > D E £
3" ) # DL,JK < C1 Y
L 1
#
N
# êë@*/ L 1
L 1
E Ñ R ¬ HH @@ ÜÜ àà ÑÑ RR
H
@ n b
á Ü à
Ö é è
3" # C1 Y EE ÑR EÑ ER EH E@ En Eb Eá EÜ Eà
3" # C1 Y
EE ÑR EÑ ER EH E@ En Eb Eá EÜ
Eà EÖ EÑÑ ERR
t! q@# 1