Skip to content

Commit

Permalink
double or single quoted strings
Browse files Browse the repository at this point in the history
  • Loading branch information
dj2 committed Jan 4, 2010
1 parent 256dff1 commit ade9e48
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/textquery/textquery_grammar.treetop
Expand Up @@ -49,7 +49,11 @@ grammar TextQueryGrammar
end

rule words
[^\']+ <WordMatch>
[^'"]+ <WordMatch>
end

rule quote
['"]
end

rule value
Expand All @@ -65,13 +69,12 @@ grammar TextQueryGrammar
end
}
/
"'" space words space "'" {
quote space words space quote {
def eval(text, opt)
words.eval(text, opt)
end
}
/
word
end

end
1 change: 1 addition & 0 deletions spec/textquery_spec.rb
Expand Up @@ -132,6 +132,7 @@ def parse(input)

# shakespeare got nothin' on ruby...
parse("'to be' OR NOT 'to be'").eval("to be").should be_true
parse('"to be" OR NOT "to be"').eval("to be").should be_true
end

it "should treat spaces as implicit ANDs" do
Expand Down

0 comments on commit ade9e48

Please sign in to comment.