Class: Scheman::Parsers::Mysql::ParsletParser

Inherits:
Parslet::Parser
  • Object
show all
Defined in:
lib/scheman/parsers/mysql.rb

Instance Method Summary collapse

Instance Method Details

#back_quoted(value) ⇒ Object



55
56
57
# File 'lib/scheman/parsers/mysql.rb', line 55

def back_quoted(value)
  str("`") >> value >> str("`")
end

#case_insensitive_str(str) ⇒ Parslet::Atoms::Sequence

Returns Case-insensitive pattern from a given string.

Returns:

  • (Parslet::Atoms::Sequence)

    Case-insensitive pattern from a given string



30
31
32
# File 'lib/scheman/parsers/mysql.rb', line 30

def case_insensitive_str(str)
  str.each_char.map {|char| match[char.downcase + char.upcase] }.reduce(:>>)
end

#comma_separated(value) ⇒ Object



63
64
65
# File 'lib/scheman/parsers/mysql.rb', line 63

def comma_separated(value)
  value >> (str(",") >> spaces? >> value).repeat
end

#double_quoted(value) ⇒ Object



51
52
53
# File 'lib/scheman/parsers/mysql.rb', line 51

def double_quoted(value)
  str('"') >> value >> str('"')
end

#non(sequence) ⇒ Parslet::Atoms::Repetation

Returns:

  • (Parslet::Atoms::Repetation)


35
36
37
# File 'lib/scheman/parsers/mysql.rb', line 35

def non(sequence)
  (sequence.absent? >> any).repeat
end

#parenthetical(value) ⇒ Object



59
60
61
# File 'lib/scheman/parsers/mysql.rb', line 59

def parenthetical(value)
  str("(") >> spaces? >> value >> spaces? >> str(")")
end

#quoted(value) ⇒ Object



39
40
41
# File 'lib/scheman/parsers/mysql.rb', line 39

def quoted(value)
  single_quoted(value) | double_quoted(value) | back_quoted(value)
end

#quoted_stringObject



43
44
45
# File 'lib/scheman/parsers/mysql.rb', line 43

def quoted_string
  single_quoted(non(str("'"))) | double_quoted(non(str('"'))) | back_quoted(non(str("`")))
end

#single_quoted(value) ⇒ Object



47
48
49
# File 'lib/scheman/parsers/mysql.rb', line 47

def single_quoted(value)
  str("'") >> value >> str("'")
end