International Conference on Contemporary Issues in IT in OIC Member Countries
U: A Computer Programming Language in Urdu A.U.Khan, A.U.Khan , Kashif Ayyub and Hafiz Farooq Khan Department of Computer Science, COMSATS Institute of Information Technology, Wah., Pakistan. email:
[email protected]
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 presented and there functionality is described. Selection statements statements of U and and and are described. The grammar of U language iterative statements such as l anguage 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, However, the alphabets of Pashto, Urdu and and Sindhi, the three major languages 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 arrangements shall be made for its being used used as official and other purposes 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 development of coding in Urdu [6][7], desktop publishing, publishing, Text-to-Speech Text-to-Speech Systems, English-to-Urdu English-to-Urdu Translation Translation Systems, etc. etc. but no conceivable work can be found 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 and evaluated evaluated from right-to-left right-to-left so, the expression 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
July 26 – 27, Islamabad, Pakistan
1
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) /01(enum) 203 (long) 4 (void) "4 (signed) "45(unsigned) 6$+ (typedef) 7" (short) 28" (int) 2,$"(const) 97" (switch) :; (return) < (else) <(default) 2.1
Data types U is a typed language and facilitates to declare 28" (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
28" 7"or 28" 7" 203or 28" 203 *+,) or*+,) ()
Data type integer 16-bit integer 32-bit integer 32-bit float 64-bit float unicode character
Meanings Declares an integer Declares a short integer Declares a long integer Declares a float Declares a double 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: >=!- A @=!-2?" A C0 -BA=7/,,) D AFG 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. + * / % =
" =-
" " "J ++
Example
! " # " " # " " "J --
July 26 – 27, Islamabad, Pakistan
Meanings Adds and Subtracts from MultipliesIand 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 " CalculatesIJKand stores back result inK 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
2
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” andM&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
Less than greater than Less than or equal to greater than or equal to equal to not equal to
examples % , is less than & , is greater than "%, is less or equal to ! "& , is greater or equal to ! "" , is 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 NI2?" D SIHHAFGRIAGEIQ AGEPIO
Similarly, the following program fragment declares three matrices , and calculates the product of matrices and and stores the resultant product into matrix :
and then
ANPTOPTOINPTOPTOKNPTOPTO,,) AUNVNW2?" D D >SWHHATRWAGEWQ AG E S VHHATR VAGE VQ SUHH AT RUAGEUQ AP VOPUOKXPUOPWO EH BA EP VOPWOI D
2.5
Control Statements U provides control statements like to complement C’s “if”, < @ in contrast to “if else” statement and < @ < @ in place of “if-else if- else” statement. The syntax of various forms of is listed as under: S YZ1Q U [ - [
S YZ1Q U [ - [ < U [ - [ <
S YZ1Q U [ - [ S YZ1Q< U [ - [ [ < S YZ1Q< U [ - [ [ < < U [ - [ <
for the C’s equivalent of “for” statement, and having the syntax: S<A YZ1 A<Q U [ - [
for the pre-condition “while” loop having the syntax of the form: S YZ1Q 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 [ - [ S YZ1Q July 26 – 27, Islamabad, Pakistan
3
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 : S 6+Q97" > F [ UDF [ 6+ [ 2,$" \ [ UD\ [ 6+ [ 2,$" U [ UDU [ 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: S V2?"Q]"2?" > AVXV:; B S4Q V^;4 > AS`U ba5-V ;`Q &?_ B SQ V; > AFG EK2?" ASKQ]" EI D ASQ V^; D
(sin) i (asin) i(sinh) j(sqrt)
Table 6: Some Mathematical Functions of U (cos) c (tan) c SdefQ + SghdQ i (acos) ci (atan) c i SdefQ + i SghdQ i (cosh) ic (tanh) icSdefQ i+ SghdQ _ (log) &+ (exp) ka" (abs)
+ SdeghdQ + i SdeghdQ + i SdeghdQ
2.7
I/O Functions Simple I/O functions l8 for output and lm; 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. 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 July 26 – 27, Islamabad, Pakistan
4
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 s ample program written in U. SQ V ;
> v @ sllm; u1 *q t7/o q Vq V q Vi"l!r sqslm; !r/ *q p"i"V ; oLnb sl_8 bnt7/ 2q*qw"i" As.& Vi" !r/ [ *q [ w"i"2?" At7/ u1*,,) APFGO V() AS` x!r/ *q p"i"`Q l ?_ AS!r/@*q@w"i"Qlm; AG Et7/ SHH Vi"A!r/ [ *q [ w"i" R Vi"AFE Vi"Q > AS` xV q Vi"`Q l ?_ AS VQlm; AS` xu1 s.&`Q l ?_ ASu1 s.&Qlm; ASu1 n s.&QE A H t7/ Et7/ ASu1 n s.&QEH t7/sl?&?_&s$0;3W "X b bX B ASt7/ `E t7/ 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.
[1] [2] [3]
[4]
[5]
[6] [7]
REFERENCES
UNS Code Page for DOS Unicode Consortium website at http://unicode.org Abdul-Majid Bhurgri, “Enabling Pakistani Languages Through Unicode”, Microsoft Corporation white paper at http://download.microsoft.com/download/1/4/2/142aef9f-1a744a24-b1f4-782d48d41a6d/PakLang.pdf 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. 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. K. Zia, “Standard Code Table for Urdu”, http://www.cicc.or.jp/english/hyoujyunka/mlit4/710Pakistan/Pakistan1.html National Language Authority web site: http://www.nla.gov.pk
July 26 – 27, Islamabad, Pakistan
5
International Conference on Contemporary Issues in IT in OIC Member Countries The Grammar of U (union) (for) (extern) !"(static) %&'(break) - (auto) (do) 203(long) "45 (unsigned) 28"(int) :;(return)
(if) (struct) y (goto) (while) () (char) .$ (register) (volatile) 4 (void) 6$+ (typedef) 2,$" (const) < (else)
(asm) (case) (continue) #"$ (sizeof) *+,) (float) (double) /01 (enum) "4 (signed) 7" (short) 97" (switch) < (default)
Do Szgg{|}~h}f@h•€hgg{e}Q o@2," Sh•€hgg{e}Qo Szgg{|}~h}f@h•€hgg{e}Q o@2," !"# $%&' o@ ‚" o@2,"2"4@2,"o@ƒL !"## $ $%&' E„„ERRE…E†E‡EbEnE@EHE (#) *+,- o@,a"@0 o@ ‚" D oxo@,a"@0 )!() /%0' . o@,a"@ o@,a"@ ˆˆ o@,a"@0 )!() /%0' 1+2 o@‰Š" o@‰Š" †† o@,a"@ ()34 5&6 o@ ‹Œ o@ ‹Œ ˆ o@‰Š" ()34 789 o@ o@ … o@ ‹Œ 1+2 o@‰ o@‰ † o@ :3)# 5,92,9 o@*,r/ o@*,r/ EE o@‰ o@*,r/ „R o@‰ )#) %;< o@*," o@*," R o@*,r/ o@*," „ o@*,r/ o@*," ER o@*,r/ o@*," E„ o@*,r/ =># %&' o@r o@r RR o@," o@r „„ o@ ," #4 /; o@ o@ H o@r o@@ o@r "3)#)(#4 /9,?
July 26 – 27, Islamabad, Pakistan
Annex-I o@] o@0Xo @ o@0 b o@ o@0Jo@
(# @?+ o@0 o@] S 6$+@"Q 3 A. o@‰!r o@0HH o@0@@ o@]#"4@ƒL o@]#"$ S 6$+@" Q#"$ 3# DBC n†HŽ #> 5EF;9 o@‰ P o O o@‰!r S # ‘@o Q o@‰!r S # ‘@o Q V@ 6$+@t V ’ o@‰!r HHo@‰!r @@o@‰!r " 5GF'9 ,$" V "HI t!q@#1 )# DL ,JK o@2," N # ‘@o o@2," M) &8N o (##%&O 2,$"@*Œ) 2,$"@28" 2,$"@( ) 2,$"@*,,) 2,$"@t,‘ M))#) $%&O &8N Y5 ˆ“Š” #!(## $%&O $P !r@28"2,$" @p !r@28"2,$" @l !r@28"2,$" @1 9// – @*q@( — ) (")(## $%&O Q2LG !4@t4@sq@ ˜” 2,$"@p !4 R!# G2E2V+TU ,S F \ T ž œ › š ™ !#G2E2 G F \ T ž œ › š ™ (#)(## $%&O WX G 2,$"@l !4@l
6
International Conference on Contemporary Issues in IT in OIC Member Countries (#)!# G2E2 WX G F \ T ž œ › =(")(## $%&O WY G• !4@1 GŸ !4@1 2,$"@1 !4@1 =(")!# G2E2 WY G F \ T ž œ › š ™ zd¡h¢ £¤¥¦§¨ #!3>> EF;9 $P !r@2L3!r @*"45 !r@*"45!r @2L3 3!3>> EF;9 &,FZ ©ª 3!3>> EF;9 $C[ «¬ (=(#(## $%&O\ ,N 9// – @*q@( — ) (=(#:3( ]F<,<U\ +,N ( ) 9//@*q@( ) ( ) (=(# \ +,N @wZ¯@®^ Q ( )*Zq sM"( )@‰ S( ) ( )@*” (:3( \ +,N ( )@t ")(:3( \ +,N VGL x° ˆ ²° ˆ ° ˆ ±° ˆ U° ˆ W° ˆ V° ˆ ° ˆ° ° ˆ `° ˆ –° >)#!(## $%&O %F%N 2,$"@‰‚4o)@*"4!r @*,,) 9//@*q@!4o) @*"4!r @*,,) >(#)(## $%&O 5,- 9//@*q@!4 ³ 9//@*q@!4 9//@*q@!4 ³ ## N& h #"4 9//@*q@!4 § #"4 9//@*q@!4 !D H@ !#:3( ]F<,<U G2E2 !4 9//@*q@!4 !4 >)#!3>> EF;9 %F%N ¢«¨¬ #!)#) $%&OV ,%K 9//@´*q@( )@t µ ,‘ #!(=(#:3( ]F<,<U\ +,NV ,%K ( )@t ,‘ 9//@*q@( )@t ,‘ ( )@t ,‘
July 26 – 27, Islamabad, Pakistan
(=(# \ +,NV,%K @wZ¯@®^ ` Q ( )*Zq sM"( )@‰ S( ) ( )@*” ##"#_F9 DU S«zh«h¡@gfzfh~h}fQ U@1 Sh•€hgg{e}@gfzfh~h}fQ U@o Sde~€e©}¡@gfzfh~h}fQ U@9q" Sgh«hdf{e}@gfzfh~h}fQ U@*7 S{fhzf{e}@gfzfh~h}fQ U@?/ S¶©~€@gfzfh~h}fQ U@·&' S¡hd«zzf{e}@gfzfh~h}fQ U @*/4 )`)##"# _F9 51a&Y2 U D t!q@#1 U D o@2,$"” U D o ##"# _F9 Ao ("3##"# _F9 ]U, B # ‘@*q@U> ##"#)# DL ,JKU _F9 U # ‘@*q@U U )(###"# _F9 9b&I2 S{¢@gfzfh~h}fQ U@ Sg¸{fd¹@gfzfh~h}fQ U@97" >##"# _F9 ,c2 U S o Q U o U S o Q #(=##"# _F9 ]b&' U S o Q97" ####"# _F9 512,P< U@ƒ U@ yl U@ =)##"# _F9 B&d U S o Qƒ ##"# _F9 e2,XG A S o QƒUyl >##"# _F9f 2,9 U S oAoAoZ!@Q >#)R Fg2E&92f 2,9 U@o U@* 4 h3"##"# _F9 iIaj U@ %&' U@‰ U@:; U@ y `##"# _F9 BC,9 A %&' (#3##"# _F9 51 A‰ #3##"# _F9kl 2+ A o :;
7
International Conference on Contemporary Issues in IT in OIC Member Countries !###"# _F9 e A t!q@#1y ()###"# _F9 <I2 o4 ()#FI2 # ‘@o4V$+@o4 ºL r/@*q@24 “L/@*,r/ ()(> HOm2 FI2 @"V$+ 6$+ @o4 ()(> nOm FI2 “L/@¼q@»L . 6$+ @" Sf½€h¡h¢Q6$+ #!()(> rC,<qUpC1 oL Sz©feQq Sh|{gfhQ .$ Sgfzf{dQ!" Sh•fh}Q*
o@2,$" E t!q@#1
(## $%&O Sde}¡{f{e}z«@h•€hgg{e}Q o@‚" () rC,< %;< B # ‘@o4 > 2,$"@t ,‘* o4 2,$"@t ,‘* ()#)# DL ,JKFI2 o4 o4 # ‘@o4 ()#)# DL ,JK <I2 oZ!@*/4 oZ!@*/4N# ‘@*/4 #()# Fg2E&92 <I2 oZ!*/4 ()#<I2 V@*4 P o@2,$" O*/4 "
#(> nOm G2 @" V @t “L/@¼q “L/@*/L1 “L/@ 6$+@28‚" 2,$" * ")#" G2 HI VGL Sf½€h¡h¢@}z~hQ V @6$+ Sd¹zQ () Sg¹efQ7" S{}fQ28" S«e}|Q2L3 Sg{|}h¡Q*"4 S©}g{|}h¡Q*"45 S¢«ezfQ*,,) S¡e©«hQ S¤ee«hz}Q*Œ) S¾e{¡Q‰4 )`##(> rC,< nOm $P- t!q@#1¼q @‰!q @V */L1 () qU 5EFU 3"(> rC,< <C1Y B # ‘@*/L1 > t!q@#1*/L1 3")# DL ,JK <C1Y L1 N # ‘@*/L1 L1 3"#C1Y t!q@#1
July 26 – 27, Islamabad, Pakistan
HI I2 V @V */L1
>3(#># sC ,;<U $ o)@*4t!q @#1V$+@o4 >3(#` o)@*4 U@9q" #)RFg2E&92 oE B # ‘@oZ! >E #)R)# DL ,JK Fg2E&92 o o # ‘@oZ! B # ‘@oZ!> #>" HI nOm t!q@#1 #> VE''U D'Y Dt!q@#1 nS!4 ˆ ( )QS@ ˆ ( )Q s o# "4@*” D( )@‰ vˆ‰ [ ˆˆ À ˆ ¿ ˆ K ˆ D!4 ™ˆšˆÀˆ\ˆFˆG 3(#3# t2,2 POSQB>DEÁ # H@nb‡†ˆ…Ž E„RÂHH@@††ˆˆ„„RR EE„RE„EREHE@EnEbE‡E† EˆE…E„„ERR
8