-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreadSQLv5.rb
More file actions
50 lines (42 loc) · 1.03 KB
/
readSQLv5.rb
File metadata and controls
50 lines (42 loc) · 1.03 KB
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
require_relative 'readio'
require_relative 'create'
require_relative 'column'
require_relative 'tableConstrain'
require_relative 'drop'
require_relative 'bt'
class Sql_parser
def parse()
bufferTokens = Readio.new()
tokens = bufferTokens.readthefile()
transitions()
tokens.each_index do |i|
#puts i
$transition.check(tokens[i])
# case tokens[i]
# when "CREATE"
# transition = $transitions.find(0)
# if transition.data == "CREATE"
# cr = Create.new(tokens, i)
# end
# when "DROP"
# dr = Drop.new(tokens, i)
# else
# puts 'Error 0'
# end
end
#$transitions.printorder()
end
def transitions
$transitions = BinaryTree.new("CREATE",0)
$transitions.add("TABLE",1)
$transitions.add("TABLE_NAME",2)
$transitions.add("(",3)
$transitions.add("COLUMN_NAME",4)
$transitions.add("COLUMN_TYPE",5)
$transitions.add("COLUMN_CONSTRAINTS",6)
$transitions.add("TABLE_CONSTRAINTS",7)
$transitions.add(");",8)
end
end
ReadSqlFile= Sql_parser.new()
ReadSqlFile.parse()