Class: OracleSqlParser::Grammar::ReservedWordGenerator::KeywordRule
- Defined in:
- lib/oracle-sql-parser/grammar/reserved_word_generator.rb
Instance Attribute Summary collapse
-
#keyword ⇒ Object
readonly
Returns the value of attribute keyword.
Instance Method Summary collapse
-
#initialize(keyword) ⇒ KeywordRule
constructor
A new instance of KeywordRule.
- #matcher ⇒ Object
- #rule_name ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(keyword) ⇒ KeywordRule
Returns a new instance of KeywordRule.
13 14 15 |
# File 'lib/oracle-sql-parser/grammar/reserved_word_generator.rb', line 13 def initialize(keyword) @keyword = keyword end |
Instance Attribute Details
#keyword ⇒ Object (readonly)
Returns the value of attribute keyword.
12 13 14 |
# File 'lib/oracle-sql-parser/grammar/reserved_word_generator.rb', line 12 def keyword @keyword end |
Instance Method Details
#matcher ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/oracle-sql-parser/grammar/reserved_word_generator.rb', line 33 def matcher matcher = [] keyword.each_char do |ch| if ch.match(/[A-Z]/) matcher << "[#{ch.downcase}#{ch.upcase}]" else matcher << "'#{ch}'" end end matcher << '( ![A-Za-z0-9] )' matcher.join(' ') end |
#rule_name ⇒ Object
29 30 31 |
# File 'lib/oracle-sql-parser/grammar/reserved_word_generator.rb', line 29 def rule_name "#{@keyword.downcase}_keyword" end |
#to_s ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/oracle-sql-parser/grammar/reserved_word_generator.rb', line 17 def to_s content = [] content << " rule #{rule_name}" content << " #{matcher} {" content << " def ast" content << " OracleSqlParser::Ast::Keyword.new(:name => text_value)" content << " end" content << " }" content << " end" content.join("\n") end |