Skip to content

Instantly share code, notes, and snippets.

@rwilkes
Forked from evernotegists/search_grammar.txt
Last active August 29, 2015 14:08
Show Gist options
  • Save rwilkes/487331acfadf682725a6 to your computer and use it in GitHub Desktop.
Save rwilkes/487331acfadf682725a6 to your computer and use it in GitHub Desktop.
Evernote Formal Search Grammar
search = [ notebook , separator ] ,
[ "any:" , separator ] ,
term ,
{ separator , term } ;
notebook = "notebook:" , ( word | quoted ) ;
word = wordchar , { wordchar } ;
quoted = '"' , { ( any - '"' ) | '\"' } , '"' ;
separator = { sepchar , separator } ;
sepchar = any - ( wordchar | '"' | "-" ) ;
term = "-" negatable
| negatable
;
negatable = literal
| expression
;
literal = word | quoted | prefix ;
prefix = { wordchar } , "*" ;
expression = label , ":" , value ;
(*
* Expression labels must be:
* The name of a NoteAttribute field (e.g. "subjectDate")
* or a ResourceAttribute field (e.g. "fileName"),
* or one of: "tag", "intitle", "created", "updated", "resource",
* "todo", or "encryption".
* Search results are undefined if an unknown label is used.
*)
label = word ;
(*
* The expression value will be interpreted based on the type of the
* field or attribute.
* Search results are undefined if the value does not match the
* required format for this field.
*)
value = nonspace | quoted ;
nonspace = { any - space } ;
space = ? whitespace character (Unicode character class Z) ? ;
wordchar = ? any Unicode Letter or Number (Unicode character classes L and N) or underscore '_' ? ;
any = ? any printable characters ? ;
</pre>
<p>
The following additional production rules indicate the expected format of expression values to match various note fields and attribute types described above.
</p><pre class="longline">boolean = "true"
| "false"
| "*"
;
double = [ "-" ] , digit , { digit } , [ "." , { digit } ]
| "*"
;
datetime = absolutedate
| relativedate
| "*"
;
absolutedate = year , month , day ,
[ "T" , hour , minute , second ] , [ "Z" ];
year = digit , digit , digit , digit ;
month = ( "0" | "1" ) , digit ;
day = ( "0" | "1" | "2" | "3" ) , digit ;
hour = ( "0" | "1" | "2" ) , digit ;
minute = ( "0" | "1" | "2" | "3" | "4" | "5" ) , digit ;
second = ( "0" | "1" | "2" | "3" | "4" | "5" ) , digit ;
relativedate = relative
| relative , "-" , { digit }
;
relative = "day" | "week" | "month" | "year" ;
digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment