0% found this document useful (0 votes)
21 views6 pages

(A) - Ada+SQL - An Overview

Ada+SQL is a programming environment that extends Ada 95 with basic SQL capabilities. It includes a compiler, interpreter, debugger and other tools. The environment provides a graphical interface to write, compile, execute and test Ada 95 programs that incorporate SQL commands. It has been distributed widely online since 1993 and includes over 190,000 lines of code developed solely by the author.

Uploaded by

Moi Jacques
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views6 pages

(A) - Ada+SQL - An Overview

Ada+SQL is a programming environment that extends Ada 95 with basic SQL capabilities. It includes a compiler, interpreter, debugger and other tools. The environment provides a graphical interface to write, compile, execute and test Ada 95 programs that incorporate SQL commands. It has been distributed widely online since 1993 and includes over 190,000 lines of code developed solely by the author.

Uploaded by

Moi Jacques
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Ada+SQL - An Overview

Arthur V. L o p e s
Universidade Luterana do Brasil
Rua Inhandui 303, Ap. 204
90.820-170 Porto Alegre, FIS -
BRAZIL
+55 (51) 241 3903
avl @ z a z . c o m . b r

1. A B S T R A C T intuitive environment from which the user has easy access


to an editor, compiler, interpreter and other tools. Ada
Ada+SQL is a programming environment for Ada capabilities available cover about 90% of the core language
95 extended with basic SQL single user specification. In addition, a set of packages have been
capabilities. It incorporates a very fast compiler added to easy programming tasks such as screen and 2D
and interpreter, with debugging options, library basic grap~cs operations. A MS-DOS console controlled
generator and browser, syntax template editors, by the PE carries out compilation and execution of
programmer wizard, two-dimensional graphics, programs, including SQL commands. The compiler and
SQL interactive interface and hypertext interpreter are assembled into one independent 32 bits
documentation on the environment, Ada 9S and program. Therefore, it is also possible to compile and run
programs from the MS-DOS command prompt. Previous
SQL. Several implementation aspects are
versions were dislributed over many Internet hosts across
discussed. dozens of countries and hundreds of several types of
1.1 Keywords institutions accounting many thousands of f~p Ixansfers from
Compilers, interpreters, programming environments, whom valuable feedback was received. These versions were
relational databases, computer education known as AVLAda9X and later AVLAda95. Ada+SQL is
programmed in ANSI C and visual C++ and contains over
2. I N T R O D U C T I O N 190,000 lines of code and results from the sole work of the
Ada+SQL is programming environment (PE) aimed to author. The executables run under both Windows 95/98 and
novice Ada and SQL programmers that has been in NT 4.0 platforms with at least four MB of available RAM.
development since November of 1993. The PE is an Six MB of disk space are needed to store the Ada+SQL

re,w _ _ . _
...............................
m
llilllll-ll
....... II1 .......... I1 ......................................................................................................................................................................................
mx I
m m E,. SQL Teems Library .Q.ptien, T e m p l a t e ,
Edit muad Decumentatien V4indew Help F:I-dFI[~
with &~bs.T~xt_IO; u~ Ada. Text_ZO~ m
proc~sdu~ Ada__SQL_Ew~xpl~ is
~ i n
~eN~t~ table Students
(Id (Long_Intogmr)
,Cour~o_Id (Integer)
.Sex (Character)
,Nax~ (String(l..30)));
insert into Studonts(10101998, I010, 'M' , " M o n i t z Taxaguizo" ):
in~rt into Students(10201998, 1010, 'F', "E1iea Cruzetaizen");
alter
~le=t
table
~ from Stud~nte
Studsnte add GPA (Float):
order by Nax~ aeoendin~; |
~nd &da__~Exa~ple; v

~ g u ~ 1 - The Ada+SQL Programming E n ~ n m e n t


installed distribution files. Three 3IA disks are used to store
the Ada+SQL distribution version.
3. P R O G R A M M I N G E N V I R O N M E N T
Permission to make digllal or hard copies of all or part or this work for The PE is a windows multiple document interface
personal or daesmom use Is granted wahoot tee provided that copies are
not made or distributed for profit or commercial advantage and that copies application named E95. The S_QLmain menu option will be
bear this notice and the full citation on the first page. shortly described below. Figure 1 shows one activation of
To copy otherwise, to republish, to post on servers or to redistnbute to lists.
requires prior specific permission and/or a fee. E95.
SIGAda'99 10/99 Redondo Beach. CA. USA
(~ 1999 ACM 1-58113-127-,5/99/0010...$5.00

157
One editing window shows an Ada program that uses SQL SQL create command has been extended with Ada 95 types.
commands. As c a n be seen the Ada 95 programming The program output for figure 1 is shown in figure 2.
language has been extended with SQL commands and the

ID COURSE_ID SEX NAME GPA

10201998 101O F Elisa Cruzstaizen 0.00


10101998 i010 M Monitz Tamaguizo 0.00

Figure 2 - O u t p u t of P r o g r a m Ada_SQL_Example
This allows the user to either write Ada code intermixed set of SQL commands interactively from the PE.
with SQL commands, as shown in figure 1, or to execute a
~1 Com,n,m~

-C.iimind (s } - ,

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . I

-I~p~ Ill ~kI~ I K II lllIi~ IIIIIII~I(1) llI~'~III'

• I~ CIWI~II I~ If( I Ill I


I lllIIIII loll II ~III~ll l i I ~ I i O.II ~
I IOlIl!llI ]LOll • I I I I l CIII~I,II.II I.II , ~ ~

Figure 3 - SQL Command Dialog Box


A specialized dialog box, activated from the SQL main SQL syntax template dialog box. Figure 4 shows the SQL
menu option, allows the specification and execution of SQL Select Command Syntax Template dialog box. The Append
commands. This dialog box is shown in figure 3. To assist to command area push button may be used to append the
on the specification of basic SQL commands a set of push formatted dialog contents to the SQL Command dialog box
buttons (.¢.reate, insert, update, select, delete, alter and Command(s) editing area.
drop) are a,

!
. . . . . . . . . . . . . .

i
|

[
• I I
. . . . . . . . . . . . . . . . . . . . lrmul- . . . . . . . .

Figure 4 - SQL Select C o m m a n d Syntax Template I)ialo w B o x

158
These syntax templates are available to assit novice generic unit components making text replacements among
programmers to code basic SOL commands. There are a set generic formal parameters and generic actual parameters.
of 60 Ada 95 syntax templates dialog boxes to assit novice Internal code generated is associated with information on
programmers to code the language constructs. both source file and line number that originated each
instruction (see figure 7). When either a compile or run-
4. COMPILER STRUCTURE time error is detected this information is used to report the
Compiler components include the usual basic modules such exact error location. The SQL select command was
that scanner, parser, symbol table management, error extended to allow, as an option, the inclusion of a block
handling, and intermediate code generation. Besides these statement. Each time a select command retrieves data, that
components a library module keeps track of source files and satisfy a where clause when present, the block statement is
the program units they contain. The library manager tells executed.
the compiler the source file that contains a given program
t,nit such that a package. A source file may contain any 4.3 Symbol Table
number of program units. For instance, when a compilation The symbol table uses a nested hash table scheme. Each
A finds a with clause that refers to a package P, the compiler instance contains a global hash table. Program
compilation makes a pause with the current source file, a. A units such that packages, main programs and SQL tables are
new compilation, B, is started to process source file, b, common entries within this scope. These types of entries
which contains package P. When compilation B concludes, have descendant hash tables. For instance, a descendant
then compilation A resumes now accumulating the program hash table for a procedure will contain all elements that
units stored in source files b and partially a. Therefore, no belong to its declarative part. Figure 6 shows the symbol
intermediate code is ever stored. Only source code is used. table representation considering the compilation for the
4.1 Scanner code fragment within figure 5. An outer square represents a
scope. Each scope contains 20 fields. Only two of these
Lexical analysis operates mostly under parser's conlrol.
fields are being shown: the father and the bucket vector.
Some subprograms belonging to predefined packages also
The father field stores a pointer to the ancestor scope. Each
use some scanner operations at run-time. To increase
bucket entry points to a linked list of table entries that share
compiler speed, the entire source file is read into a memory
buffer by one low-level input system call. A token look- the same hash value. Figure 6-(a) shows the entries Ada and
ST. A full symbol table entry contains 65 fields from which
ahead buffer of varying length is used to provide the parser
many are pointers into other data structures. Only two of
with a means of inspecting the source code in order to
these fields are being shown:/d and son. The id field stores
identify specific language constructs. Examples of such
the characters that represent the symbol. Names, all forms
constructs are aggregates and SQL commands. The use of
of literals and temporaries are common symbol table
context clauses and generic units cause the parser to switch
its focus among a number of source files. Subprograms that entries. The son field stores a pointer into its descendant
store all scanner information into its local storage are used scope for entries like packages subprograms and records.
to deal with this problem. The scanner parameters are then Figure 6-(b) shows the descendant scope for procedure ST.
initialized with the information needed to compile the new Figure 6-(c) shows the descendant scope for package Ada.
coming compilation and the parser is then called to act on Experiments have shown that this structure is responsible
for part of the compiler speed.
it. When the parser returns these subprograms restore the
scanner information with the previously saved local storage w~:h Ada.Text_IO; u e e Acla.Text_IO;

allowing the parser to resume its work with the source file pEOC~Et ST ~S
that caused this type of action. ~=yIMn Date As .t'm~O~l.
Month : Integer;
4.2 Parser Day : Integer;
Syntax analysis is performed by a recursive descendant
parser (k) where k stands for any number of look-ahead
tokens. As pointed out before, language constructs such as
Year : Integer;
aggregates and SQL commands require a number of look-
a n d z~=ozdl
ahead tokens in order to be identified properly. SQL
commands are parsed by context. SQL commands may be f u m a t L o m Fat (N : Integer)
also coded anywhere an Ada statement is allowed. As zotuxm Long_Integer is
mentioned before, instantiation of generic units cause the 1~gLn
parser to save the scanner state and redirect its input to the Figure 5 - Fragment of an Ada 95 Program

159
father

^ I Ud eaR Son
Ada

//
~ f a t h e
Id ... So~ father
Id

/1"--'°1
... Son

I-I-
bucl~
Fat
i /
(~

bucket bucket
0o) (c)
Figure 6 - Partial Symbol Table Representation
Pre-defined package specifications are only stored within Examples of three operand instructions are related to the
the symbol table when refereed. first, last, length and range attributes. Four operand
instructions are used to implement SQL constructs such as
4.4 Error Handling the one shown in figure 8, part (b). Inslruction number 48
A simple sUrategy is used for dealing with errors. Once an shows an intermediate instruction that implements the
error is detected it is reported and the compiler terminates. where clause shown in part (a),
Over one thousand messages are used in both English and
Hn~*- 16 ~lJ g Eil,* L6 Ei~,a, 32 Ba,J
Portuguese. Two external programs are used to format and
display the error messages.

4.5 Intermediate Code


I__ CodaJ Sm=ceYb ] l O p C o . S°u~°':rile Opesmsdl

82~1~ 16~ 32]~1 32J~U


The intermediate code is based on a set of 166 instructions.
Figure 7 shows the layout for the five types of instructions.
Calls for built-in subprograms use a set of one-operand
I oo.1,oo,-I
(o) Two Op ~.w.d~
instructions. Each actual parameter generates a push
81B~I~ 16 B~i~ ~0 IB~a ~12'IP.~- ~l~l~
address instruction. An additional push address instruction
is used for a function's return value. The actual subprogram
call use a one-operand instruction. The operand field, for
i oool0-,ol
c~'rlme c~eanm~
this instruction, contains the memory address of the built-in
i~ 16 l~ta 32~ 33g~ ZI~ 33~
subprogram. Unconditional branches, enter block, leave
block, return and other specialized instructions use only one
operand. Assignment statements, conversions, goto if true
instructions use two operands.
Figure 7 - IAy-out of Intermediate Instructions

160
select ~ from Grades where ~s ~e no~ in ("AP", "IN" ) ;
(a) Select C o m m a n d
Inst,uc~on#
/ Souzce file#
//.__-. Source line#
44 0 ? I_SOL_OPEN_WRITE $Select I 724168
45 0 7 I SQL SELECT START NOTAS $Index GRADES 1
46 0 ? I SQL_EOF $ Index_GRADES_I g o t o 60
47 0 7 I_SQL_READ H O T A S $'rndex G R A D E S .1 m

48 0 7 I_SQL_IS_IN_SET O B S $ S Q L S E T IS I N 1 $ S Q L SET is in 1 1
49 0 7 I SQL NOT $ S Q L S E T is i n 1 g o ~ o 5 8
50 0 7 I_SQL ADD_ONE $Select: I
Q I |

57 O ? I_SQL_MRITE $Selec~ 1
58 0 7 Z_SQL._NEXT GRADES $1ndex GRADES 1
59 0 7 I DIRECTGOTO 46
(b) Intermediate Code
Figure g - Intermediate Instructions

4.6 Graphics disk files with special headers that contain information on
Basic two-dimensional graphics allows the following tuple utilization.
operations: window creation and des.laction, line. text~
6. Aria 95 & SQL CONSTRUCTS
pixel, ellipse and circle. It uses the Windows MFC CDialog
Most core conslructs of Ada 95 are operational. Variant
and CDC classes from a console application. Other
parts, access to subprogram definition, dynamic
complementary MPC classes are also used. These resources
dispa¢l~ng, abstract types and subprograms, named array
and related types are accessed from Ada programs by using
aggregates, user-defined assignment and finalization,
the implementation-defined package Windows_2D.
requeue statements, asynchronous "ansfer of control,
5. INTERPRETER shared variables, praginas and a number of attributes are
The symbol table and the intermediate code represent any cons~'uets under implementation.
set of compiled program units. This representation together SQL commands available are create, insert, update, select,
with a non empty set of run-time stacks are used by the delete, alter and drop.
Ada+SQL abstract machine which is implemented by an
interpreter. Each task and protected units have their own 7. DOCUMENTATION
stack. The tasking model implementation uses a round Full hypertext documentation is provided on the
robing scheduler. The user can change the quantum as a environment, the Ada 95 Referenc~ Manual V. 6.0, SQL. In
way of experimenting different concurrent program addition, a tutorial on basic Ada 95 is also provided. The
behavior. When a dead state is detected among a set of E95.I-ILP compressed file is accessed from within the PE
tasks these tasks are placed in the abnormal state and the and also fTom the winhelp utility program.
exception Tasking_Error is raised. The stack model is used
8. PERFORMANCE
as the run time storage management strategy. Two
Running the compiler/interpreter on a COMPAQ Presario
exceptions are the allocation of dynamic memory, requested
300MHz under Windows 98 with 502 Ada source files,
explicitly by the programmer, and the occurrence of
where some sources contain more than one program unit,
unconstrained arrays. For instance, the bounds of an
with a total of 61,000 LOC.s takes less than two minutes to
unconstrained array declared within a subprogram may be
compile and interprete. A few of these programs use delay
taken from parameters. Only when such subprogram is
statements which increased the overall elapsed time.
executed the array storage area is allocated. These arrays
make use of descriptors that point to memory allocated 9. CONCLUSIONS AND FUTURE WORK
from the heap. Special memory controls are used to avoid Ada+SQL has been used as a tool to assist novice
memory leaks when a block containing such arrays leaves programmers enrolled in Data Smlcmres and Concurrency
the stack. Aria 95 and SQL commands are interpreted as the classes for several years at undergrsduate CS programs in
same level. The current version treats tables as independent the "Universidade Luterana do Brasil" located in the cities

161
of Canoas and Gravataf both within the state of Rio Grande [ l l ] A d a 95 Rationale - The Language - The Standard
do Sul, Brazil. Students' reactions indicate that Ada+SQL Libraries. Intermetrics, Inc., Cambridge, Ma, 1995.
has been helpful to them. Future work will continue to [ 12] Bacon, J. Concurrent Systems, Addison-Wesley, 1996.
implement additional Ada 95 and SQL consu'ucts as well as
improving the PE. Special attention is being given to [13]Ben-Ari, M. Principles od Concurrent Programming,
incorporate some Visual Basic features that could make its Prentice-Hall, 1982.
usage easier as well as CGI capability. Version 3.0 of [14]Cormen, T. H. et al. InUroduetion to Algorithms. 15 ed.
Ada+SQL will be distributed upon request for a limited McGraw-Hill, 1995.
period of time. [15]Aho, A.V. et al. Data Structures and Algorithms, 28 ed.
10. REFERENCES Addison-Wesley, 1987.
[1] Hawryszkiewycz, I. T. Database Analysis and Design. [16]Aho, A.V., Sethi, R. and Ullman, J. D. Compilers,
Science Research Associates, 1984. Principles, Techniques, and Tools. Addison Wesley,
[2] Bradley, J. File. Data Base Techniques. CBS College 1985.
Publishing, 1982. [17]Aho A. and Ullman, J. D. The Theory of Parsing,
[3] Date, C. J. An Introduction to Database Systems. Translation and Compiling. Prentice-Hall, 1972.
Addison Wesley, 1977. [18] CJries, D. Compiler Conslruction for Digital
[4] Date, C. J. and Darwen, Hugh. A Guide To Sql Computers. John Wiley & Sons, 1971.
Standard. Addison Wesley, 1996. [19]Fisher, C. N. and LeBlanc, R. J. Crafting a Compiler.
[5] Ladanyi, H. Sql Unleashed; The Comprehensive Benjamin Cummings, 1988.
Solutions Package With Cdrom. Sams, 1997. [20] Hopcroft, J. D., Ullman, J. D. Introduction to Automata
[6] Lopes, Arthur V. '2ntrodu~o ~t Programaf~o coin Ada Theory, Languages and Computation. Addison Wesley,
95," Ed. ULB R.A, 1997. 1979.
[7] Lopes, Arthur V. "Estruturas de Dados para [21]Harvey, T. J. and Cooper, K. D. Compiler-Controled
Constru~o de Software," Volume 1 - "Nfvel B~ico," Memory. In Proceedings of the 8th International
Ed. ULBRA, 1999. Conference on Architectural Support for Programming
[8] Lopes, Arthur V. "Estruturas de Dados para Languages and Operating Systems, San Jose, October
ConstruqAo de Software," Volume 2 - "Nfvel 1998, pp. 2-11, volume 33, number 10. ACM Press,
Intermedi(trio," Ed. ULBRA, 1999. 1998.
[9] Freeze, Wayne. The Sql Programmer's Reference, With [22] Sebesta, R. W., Concepts of Programming
Cd. Ventana Press, 1998. Languages,3" Ed. Addison-Wesley, 1996.
[10] Ada 95 Reference Manual. Intermetrics, Inc.,
Cambridge, Ma, 1995. ANSIfISO-8652:1995.

162

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy