-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcolumn_constraints.rb
68 lines (58 loc) · 1.86 KB
/
column_constraints.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
class Column_Constraints
$times_in = 0
def initialize()
puts 'In Column_Constraints class'
#columnConstraintsCheck(token)
end
def columnConstraintsCheck(token)
constraints_variables = Hash["NOT" => 1, "NULL" => 2, "DEFAULT" => 3]
case token
when /^[a-zA-Z]*,$/
puts "column Constraint with ,"
puts 'Make split here then seek the key in The Constraint_Variables'
theType = token.split(',')
if constraints_variables.has_key?(theType[0])
theKey = theType[0]
theVal = constraints_variables[theKey]
puts "The Constraint is : #{theVal}"
#$column_definition_type = theVal
return true
#return "Go_To_bracket_Transition"
else
$times_in = 0
return token
end
when /^'[a-zA-Z]*|\d*',$/ #handel ex. "'1'," or "'new',"
puts "column Constraint with '', "
puts 'Make split here then seek the key in The Constraint_Variables'
puts "The Constraint is : #{token}"
return true
when /^[a-zA-Z]*[a-zA-Z]*[a-zA-Z]*$/i
puts 'column Constraint is letters only'
if constraints_variables.has_key?(token)
theKey = token
theVal = constraints_variables[theKey]
puts "The Constraint is : #{theVal}"
#$column_definition_type = theVal
return "Go_To_Col_type_Transition"
else
$times_in = 0
return token
end
#when ");"
# return "Go_TO_END"
#when "PRIMARY"
# return "Go_to_Table_Constraints"
else
puts 'Error, column Constraint is not valid.'
$times_in = 0
return token
end
end
def in_class_times_increase()
$times_in = $times_in + 1
end
def in_class_times()
return $times_in
end
end