Skip to content

Instantly share code, notes, and snippets.

@itod
Last active December 15, 2015 05:19
Show Gist options
  • Select an option

  • Save itod/5208009 to your computer and use it in GitHub Desktop.

Select an option

Save itod/5208009 to your computer and use it in GitHub Desktop.
Simple ParseKit Expression Language grammar
@symbols = '!=' '<=' '>=';
@start = expr;
expr = orExpr;
orExpr = andExpr orTerm*;
orTerm = 'or' andExpr;
andExpr = relExpr andTerm*;
andTerm = 'and' relExpr;
relExpr = callExpr (relOp callExpr)*;
relOp = '<' | '>' | '=' | '!=' | '<=' | '>=';
callExpr = primaryExpr ('(' argList ')')?;
argList = Empty | atom (',' atom)*;
primaryExpr = atom | '(' expr ')';
atom = obj | literal;
obj = id member*;
id = Word;
member = '.' id;
literal = QuotedString | Number | bool;
bool = 'yes' | 'no';
@itod
Copy link
Copy Markdown
Author

itod commented Mar 20, 2013

// This grammar will parse simple relational boolean expressions like:

foo and bar

(foo or bar) and yes

foo.bar(20) >= 10.0

foo.bar("hello") != "hello"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment