Class: OracleSqlParser::Grammar::ReservedWordGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/oracle-sql-parser/grammar/reserved_word_generator.rb

Defined Under Namespace

Classes: KeywordRule, MatchKeyword

Class Method Summary collapse

Class Method Details

.generate_grammerObject



4
5
6
7
8
9
# File 'lib/oracle-sql-parser/grammar/reserved_word_generator.rb', line 4

def self.generate_grammer
  filename = ARGV[1] || File.expand_path("./reserved_word.treetop", File.dirname(__FILE__))
  File.open(filename, 'w') do |f|
    f.write self.generate_grammer_string(filename)
  end
end

.generate_grammer_string(filename) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/oracle-sql-parser/grammar/reserved_word_generator.rb', line 62

def self.generate_grammer_string(filename)
  header = <<EOS
#
# #{File.basename(filename)} generated by #{__FILE__} at #{Time.now}
#
module OracleSqlParser::Grammar
  grammar ReservedWord
EOS
  content = []

  footer = <<EOS
  end
end
EOS
  not_match_keyword = MatchKeyword.new 'keyword'
  self.keywords.each do |keyword|
    rule = KeywordRule.new(keyword)
    content << rule.to_s
    not_match_keyword << keyword
  end

  content.unshift not_match_keyword.to_s
  header + content.join("\n") + footer
end

.keywordsObject



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
# File 'lib/oracle-sql-parser/grammar/reserved_word_generator.rb', line 87

def self.keywords
  [
    'ACCESS',
    'ADD',
    'ALL',
    'ALTER',
    'AND',
    'ANY',
    'AS',
    'ASC',
    'AT',
    'AUDIT',
    'BETWEEN',
    'BY',
    'CASE',
    'CAST',
    'CHAR',
    'CHECK',
    'CLUSTER',
    'COLUMN',
    'COLUMN_VALUE',
    'COMMENT',
    'COMPRESS',
    'CONNECT',
    'CREATE',
    'CROSS',
    'CUBE',
    'CURRENT',
    'CURRENT_OF',
    'CURRVAL',
    'CURSOR',
    'DATE',
    'DAY',
    'DBTIMEZONE',
    'DECIMAL',
    'DEFAULT',
    'DELETE',
    'DESC',
    'DISTINCT',
    'DROP',
    'ELSE',
    'EMPTY',
    'END',
    'ESCAPE',
    'EXCLUSIVE',
    'EXISTS',
    'FETCH',
    'FILE',
    'FIRST',
    'FLOAT',
    'FOR',
    'FROM',
    'FULL',
    'GRANT',
    'GROUP',
    'HAVING',
    'IDENTIFIED',
    'IMMEDIATE',
    'IN',
    'INCREMENT',
    'INDEX',
    'INFINITE',
    'INITIAL',
    'INNER',
    'INSERT',
    'INTEGER',
    'INTERSECT',
    'INTO',
    'IS',
    'JOIN',
    'LAST',
    'LEFT',
    'LEVEL',
    'LIKE',
    'LIKE2',
    'LIKE4',
    'LIKEC',
    'LOCAL',
    'LOCK',
    'LONG',
    'MAXEXTENTS',
    'MEMBER',
    'MINUS',
    'MLSLABEL',
    'MODE',
    'MODIFY',
    'MONTH',
    'NAN',
    'NATURAL',
    'NESTED_TABLE_ID',
    'NEXT',
    'NEXTVAL',
    'NOAUDIT',
    'NOCOMPRESS',
    'NOT',
    'NOWAIT',
    'NULL',
    'NULLS',
    'NUMBER',
    'OF',
    'OFFLINE',
    'OFFSET',
    'ON',
    'ONLINE',
    'ONLY',
    'OPTION',
    'OR',
    'ORDER',
    'OUTER',
    'PCTFREE',
    'PERCENT',
    'PRIOR',
    'PRIVILEGES',
    'PUBLIC',
    'RAW',
    'REGEXP_LIKE',
    'RENAME',
    'RESOURCE',
    'REVOKE',
    'RIGHT',
    'ROLLUP',
    'ROW',
    'ROWID',
    'ROWNUM',
    'ROWS',
    'SECOND',
    'SELECT',
    'SESSION',
    'SESSIONTIMEZONE',
    'SET',
    'SHARE',
    'SIBLINGS',
    'SIZE',
    'SMALLINT',
    'START',
    'SUBMULTISET',
    'SUCCESSFUL',
    'SYNONYM',
    'SYSDATE',
    'SYSTIMESTAMP',
    'TABLE',
    'THEN',
    'TIES',
    'TIME',
    'TO',
    'TRIGGER',
    'TYPE',
    'UID',
    'UNION',
    'UNIQUE',
    'UPDATE',
    'USER',
    'USING',
    'VALIDATE',
    'VALUES',
    'VARCHAR',
    'VARCHAR2',
    'VIEW',
    'WAIT',
    'WHEN',
    'WHENEVER',
    'WHERE',
    'WITH',
    'YEAR',
    'ZONE',
  ]
end