Method: Fast.parse_sql
- Defined in:
- lib/fast/sql.rb
.parse_sql(statement, buffer_name: "(sql)") ⇒ Fast::Node
ast = Fast.parse_sql(“select ‘hello AST’”)
=> s(:select_stmt,
s(:target_list,
s(:res_target,
s(:val,
s(:a_const,
s(:val,
s(:string,
s(:str, "hello AST"))))))))
‘s` represents a Fast::Node which is a subclass of Parser::AST::Node and has additional methods to access the tokens and location of the node. ast.search(:string).first.location.expression
=> #<Parser::Source::Range (sql) 7...18>
49 50 51 |
# File 'lib/fast/sql.rb', line 49 def parse_sql(statement, buffer_name: "(sql)") SQL.parse(statement, buffer_name: buffer_name) end |