Class: Fast::SQL::SourceBuffer
- Inherits:
-
Parser::Source::Buffer
- Object
- Parser::Source::Buffer
- Fast::SQL::SourceBuffer
- Defined in:
- lib/fast/sql.rb
Overview
The SQL source buffer is a subclass of Parser::Source::Buffer which contains the tokens of the SQL statement. When you call ‘ast.location.expression` it will return a range which is mapped to the tokens. ast = Fast::SQL.parse(“select 1”) ast.location.expression # => #<Parser::Source::Range (sql) 0…9> ast.location.expression.source_buffer.tokens
> [
<PgQuery::ScanToken: start: 0, end: 6, token: :SELECT, keyword_kind: :RESERVED_KEYWORD>,
<PgQuery::ScanToken: start: 7, end: 8, token: :ICONST, keyword_kind: :NO_KEYWORD>]
Instance Method Summary collapse
Instance Method Details
#tokens ⇒ Object
76 77 78 |
# File 'lib/fast/sql.rb', line 76 def tokens @tokens ||= PgQuery.scan(source).first.tokens end |