Introduction
Objective-C NSPredicate, NSExpression parser in Golang. Created for own usage and work.
Compiling & Running Objective-C and Swift file
Objective-C
gcc -framework Foundation ./objective-c/example.m
Swift
swift ./swift/example.swift
The [cd] flags
[c] flag will enable case-insensitive filtering.
[d] flag will enable diacritic-insensitive filtering.
Examples of diacritics include French accent marks, German umlauts and 'sharp s', Spanish 'tilde n'.
e.g.
René Descartes
vs Rene Descartes
Français
vs Francais
reiß
vs reiss
español
vs espanol
alphabet = "a" | "b" | ... | "z" | "A" | "B" | ... | "Z" ;
(omitted for brevity)
digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;
operator = "==" | "=" | "!=" | "<" | "<=" | ">=" | ">" | "beginswith" | "endswith" | "contains" | "matches" ;
logical operator = "and" | "or" | "all" | "any" ;
special value = "true" | "false" | "YES" | "NO" | "NULL" | "nil" ;
blank = " " | "\n" \ "t" | "\r" | "\f" | "\b" ;
symbol = "(" | ")" | "[" | "]" | "{" | "}" | "," ;
identifier = { "_" } , alphabet , { alphabet | digit | "_" } ;
quotes = "'" | '"' ;
Documentation
NSPredicate | Apple Documentation
NSExpression | Apple Documentation
Predicate Programming Guide | Apple Documentation Archive
token module | Go Standard Library
scanner module | Go Standard Library
ast module | Go Standard Library
Reference & Article
Article on NSPredicate by Fluffy.es (Axel)
Handwritten Parsers & Lexers in Go by Ben Jonhnson
SQL parser in Go by Mariano Gappa
NSPredicate by Mattt
Introduction to Abstract Syntax by Arkadiusz Ziobrowski