Transcript Lingu

Lingu
A light weight language for critical
data processing
Agenda
•
•
•
•
•
Brief Description
Current Goal
System Design
Progress
Conclusion
Background
• Many organizations run mission critical
data processing application.
• Validation & testing is very critical in such
application.
• In practice, testing is considered an extra
burden to the programmer.
• Most languages don’t treat validation &
testing as an integral part of programming.
The Idea
• The idea is to enforce validation and
testing to programmer.
• This is done by embedding validation
script on the programming language.
• Lingu is created based on the idea above.
Lingu
• A Lightweight language to program data
transformation on database.
• High level Language.
• Small → Simplifies Lingu's internal logic and the
verification of Lingu's programs.
• Sufficient construct to program a large class of
useful data transformations.
• Built-in feature to generate random inputs and to
report the test results (validation).
Case Study
• The prototype development is based on
“Agenda & Appointment” sample from
Lingu script on RUTI Midterm Report July
2004.
Lingu Class
type Agenda = Dbase {|
Old :: Table Appointment
; Main :: Table Appointment |}
type Appointment = Record
{| Date :: Date
; Priority :: Integer
; Note :: String |}
class AgendaUtility (a :: Agenda)
method cleanup (d::Date) :: ()
do
{ insertAll x<-a.Main where x.Date<=d to a.Old ;
delete m<-a.Main where x.Date<=d
}
method emptyOld () :: ()
do
a.Old := <| |>
Lingu Validation Script
validation test1 (i::Integer; d::Date) :: Bool
local
x :: Appointment ;
b1,b2 :: Bool
do
{ x := a.Main!!i ;
call cleanup(d) ;
b1 := find x' <- a.Main
where x' = x
found T otherwise F ;
b2 := find x' <- a.Old
where x' = x
found T otherwise F
}
return (b1 \/ b2)
pre 0 <= i /\ i < #a.Main
post return=T
scenario
test1(0,currentDate()) ;
test1(#a.Main-1,currentDate()) ;
test1(#a.Main,currentDate())
Current Goal
• Develop a working prototype based on
Java programming language
• Functionality :
– Interpreter and Syntax Checker for Lingu
– Connection Database, Lingu-SQL translator
– Database test generator
– Compiler is not included
System Design
Lingu Script
Lingu Class
Lingu Class
Translator
Lingu
Validation
Lingu-Java
Interpreter
Java Class
Syntax
Checker
Validation
Process
Database
Connection &
Test Generator
Syntax Checker
• Inspecting the syntax of Lingu script based
on the grammar.
• The EBNF grammar is created from the
case study script.
• Status : In progress, basic functionality.
Lingu Class Translator
• Translating Lingu Classes to Java Classes
type Agenda = Dbase
{|
Old :: Table Appointment
; Main :: Table Appointment
|}
public class Agenda {
private Appointment[] Old;
private Appointment[] Main;
public void setOld(Appointment[] Old) {
this.Old = Old;
}
public void setMain(Appointment[]Main) {
this.Main = Main;
}
public Appointment[] getOld() {
return this.Old;
}
public Appointment[] getMain() {
return this.Main;
}
}
Lingu Class Translator
• Status : In progress, limited to the sample
script
Lingu-Java Interpreter
• Parsing and executing the Lingu script in a
database environment.
• Extract the script into a parse tree using
JJTree.
Parse Tree
validation test1 (i::Integer; d::Date) :: Bool
local
x :: Appointment ;
b1,b2 :: Bool
do
{ x := a.Main!!i ;
call cleanup(d) ;
.
.
.
}
Parse Tree
Validation
Test1
Param
Body
i
bool
d
integer
Return
date
Declaration
x
appointment
Assignment
B1
B2
bool
bool
Lingu-Java Interpreter
• Some of the functionality is hard-coded for
prototyping purpose.
• Status : In progress, 60 %
Database Connection
• Handling the communication from
interpreter to the database.
• Database connection using JDBC and
MySQL as the database server.
• Database conenction functionality is
limited to CRUD (Create,Update,Delete)
operation.
• Status : In progress
Test Generator
• Automatically populate the database with
random inputs for validation purpose.
• Random inputs structure is according to
the Lingu class.
• Test Generator development is currently
being started.
Afterwords
• Lingu is a work in progress.
• The real Lingu is implemented with
attribute grammar.
• The work is not final, it is open to criticsm
and suggestion.
End of Presentation