-
Notifications
You must be signed in to change notification settings - Fork 0
/
test2.rb
52 lines (51 loc) · 1.07 KB
/
test2.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
require "mod1.rb"
require "rubygems"
require "xmlsimple"
input="Account:bal:bal + #amt + 10:id = #id"
$object=XmlSimple.xml_in("./objects/obj.xml")
$input={"id"=>"101","amt"=>"1001001"}
include Validations
str=input.split(":")
object={}
table=str[0]
lhs=str[1]
rhs=str[2]
cond=str[3]
#puts "rhs = #{rhs}"
$object['object'].each do |obj|
if(obj['name'][0]['value']==table)
object=obj
end
end
if object=={}
puts "error: Table Does Not Exist"
end
#puts object['attr']
index=1
while index<str.length
rhs_split=str[index].split(" ")
i=0
while i<rhs_split.length
if rhs_split[i][0]==35 ##ascii value of #=35
temp=rhs_split[i].split("#")[1]
rhs_split[i]=$input[temp]
elsif is_i?(rhs_split[i])
puts ""
else
flag=false
object["attr"].each do |attr|
if(attr["content"]==rhs_split[i])
flag=true
end
end
if flag==false
puts "invalid while creating operation"
end
end
i=i+1
end
str[index]=rhs_split.join(" ");
index=index+1;
end
puts "str output"
puts str