Sunday, January 30, 2011

SQL99 grammar problem for the LL(k) parser.

When I define ANTLR SQL99 grammar, I encountered the problem that SQL grammar has rules that are mutually left-recursive.

For example, the boolean value expression is cyclic as following:

boolean value expression
-> boolean term
-> boolean factor
-> boolean test
-> boolean primary
-> predicate
-> comparison predicate
-> row value expression
-> row value special case
-> value expression
-> boolean value expression

So, I think that I define the value expression as the root,

value expression
-> boolean value expression
-> boolean term
-> boolean factor
-> boolean test
-> boolean primary
-> predicate
-> comparison predicate
-> row value expression
-> row value special case
-> (value expression is omitted)

and the place that boolean value expression is referenced by the other element of grammar is rewritten by the value expression.
Similarly, the row value expression is rewritten by the value expression, but I encountered a problem again.

The row value expression is refered by both comparison predicate and between predicate.
But I don't know the priority of the comparison and between predicates.

For instance, the following expression

A = B BETWEEN C AND D

is

(A = B) BETWEEN C AND D

or

A = (B BETWEEN C AND D)

?

First, I will define priority of the predicates in order of the grammar definition.

Sunday, January 23, 2011

Test data generation tool (3)

I thought using Irony .NET for analyzing SQL but I think using ANTLR now.
I experiment on analyzing SQL by ANTLR and I am making SQL99 grammar with reference to this site.
SQL is difficult ... .

Saturday, January 15, 2011

Test data generation tool (2)

I am making a tool that generates test data from a given SQL.
I think the architecture of the tool as the follow component diagram.

Saturday, January 8, 2011

Test data generation tool

I am making a tool which generates test data from SQLs.
The tool analyzes SQLs  and solves its WHERE clauses and the solution is used as the test data of the SQLs.

For example, think the following SQL
SELECT * FROM table1 WHERE table1.col1 >= 2

In WHERE clause, solve table1.col1 >= 2 and we get a solution table1.col1 = 2.
I think this data can be test data for the SQL.

I use Irony for analyzing SQLs and Z3 for solving the WHERE clauses of SQLs.

Saturday, January 1, 2011

Memo for developing web application

I write reminders for web application systems.

1. The session should contain only user information
 The server session contains only login  user information and http request parameters contains user id for operations and we have to check that the login user has the permission for the operations.

2. Separating links and buttons for the page transition
 Use link for the get method of http request and button for the post method of http request.

3. Method for long URI
 If we input words for the search conditions and the words are many, url is too long.
 It seems good for me to implement URI shortening service inside the system.