Class: PgVerify::EbnfParser::Ast
- Inherits:
-
Object
- Object
- PgVerify::EbnfParser::Ast
- Defined in:
- lib/pg-verify/ebnf_parser/ast.rb
Instance Attribute Summary collapse
-
#map ⇒ Object
Returns the value of attribute map.
Instance Method Summary collapse
- #find_variables(element = @map) ⇒ Object
-
#initialize(map) ⇒ Ast
constructor
A new instance of Ast.
Constructor Details
#initialize(map) ⇒ Ast
Returns a new instance of Ast.
8 9 10 |
# File 'lib/pg-verify/ebnf_parser/ast.rb', line 8 def initialize(map) @map = map end |
Instance Attribute Details
#map ⇒ Object
Returns the value of attribute map.
6 7 8 |
# File 'lib/pg-verify/ebnf_parser/ast.rb', line 6 def map @map end |
Instance Method Details
#find_variables(element = @map) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/pg-verify/ebnf_parser/ast.rb', line 12 def find_variables(element=@map) # TODO: Actually parse the variables # puts "REC #{element.class}: #{element}" # puts "\n" # ret = [] # ret += element.map { |val| find_variables(val) }.flatten if element.is_a?(Array) # element.each { |key, value| # # We found a variable if we found a value which is not a number nor a boolean constant # if key == :Value && value.is_a?(String) && !(/\d+/.match?(value)) && value != 'true' && value != 'false' # ret << value # end # ret += find_variables(value) # } if element.is_a?(Hash) # return ret end |