Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from pangloss/fast_parser
Fast parser
- Loading branch information
Showing
11 changed files
with
462 additions
and
450 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
require 'pacer/filter/where_filter/node_visitor' | ||
|
||
module Pacer | ||
module Routes | ||
module RouteOperations | ||
def where(str, values = {}) | ||
chain_route :filter => :where, :where_statement => str, :values => values | ||
end | ||
end | ||
end | ||
|
||
module Filter | ||
module WhereFilter | ||
attr_reader :where_statement | ||
attr_accessor :values | ||
|
||
def where_statement=(str) | ||
@where_statement = str | ||
@built = @parsed = @intermediate = nil | ||
end | ||
|
||
def parsed | ||
@parsed ||= JRuby.parse @where_statement | ||
end | ||
|
||
def intermediate | ||
@intermediate ||= parsed.accept(NodeVisitor.new(self, values || {})) | ||
end | ||
|
||
def build! | ||
@built ||= intermediate.build | ||
end | ||
|
||
protected | ||
|
||
def attach_pipe(end_pipe) | ||
pipe = build! | ||
pipe.setStarts end_pipe if end_pipe | ||
pipe | ||
end | ||
|
||
def inspect_string | ||
"where(#@where_statement)" | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.