diff options
author | tg(x) <*@tg-x.net> | 2016-10-05 00:02:10 +0200 |
---|---|---|
committer | tg(x) <*@tg-x.net> | 2016-10-05 00:02:10 +0200 |
commit | ec62d29c90958aa8d41474ed2fe5a179d6fafed7 (patch) | |
tree | 367cc55bc6772cf194ed6c4778cd344d581d3d7c /thirdparty/jed/plurals.jison | |
parent | fda241d74d5c1c39203b64da676c684d4dc9d800 (diff) | |
parent | d3ccf4103900b8d990b1970d135695b938d94eae (diff) | |
download | wallet-core-ec62d29c90958aa8d41474ed2fe5a179d6fafed7.tar.xz |
Merge branch 'master' of taler.net:/var/git/wallet-webex
Diffstat (limited to 'thirdparty/jed/plurals.jison')
-rw-r--r-- | thirdparty/jed/plurals.jison | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/thirdparty/jed/plurals.jison b/thirdparty/jed/plurals.jison new file mode 100644 index 000000000..9364f994e --- /dev/null +++ b/thirdparty/jed/plurals.jison @@ -0,0 +1,72 @@ +/* description: Parses end executes mathematical expressions. */ + +/* lexical grammar */ +%lex +%% + +\s+ /* skip whitespace */ +[0-9]+("."[0-9]+)?\b return 'NUMBER' +"n" return 'n' +"||" return '||' +"&&" return '&&' +"?" return '?' +":" return ':' +"<=" return '<=' +">=" return '>=' +"<" return '<' +">" return '>' +"!=" return '!=' +"==" return '==' +"%" return '%' +"(" return '(' +")" return ')' +<<EOF>> return 'EOF' +. return 'INVALID' + +/lex + +/* operator associations and precedence */ + +%right <code> '?' ':' +%left '||' +%left '&&' +%left '<=' '>=' '<' '>' '!=' '==' +%left '%' + +%start expressions + +%% /* language grammar */ + +expressions + : e EOF + { return { type : 'GROUP', expr: $1 }; } + ; + +e + : e '?' e ':' e + {$$ = { type: 'TERNARY', expr: $1, truthy : $3, falsey: $5 }; } + | e '||' e + {$$ = { type: "OR", left: $1, right: $3 };} + | e '&&' e + {$$ = { type: "AND", left: $1, right: $3 };} + | e '<' e + {$$ = { type: 'LT', left: $1, right: $3 }; } + | e '<=' e + {$$ = { type: 'LTE', left: $1, right: $3 };} + | e '>' e + {$$ = { type: 'GT', left: $1, right: $3 };} + | e '>=' e + {$$ = { type: 'GTE', left: $1, right: $3 };} + | e '!=' e + {$$ = { type: 'NEQ', left: $1, right: $3 };} + | e '==' e + {$$ = { type: 'EQ', left: $1, right: $3 };} + | e '%' e + {$$ = { type: 'MOD', left: $1, right: $3 };} + | '(' e ')' + {$$ = { type: 'GROUP', expr: $2 }; } + | 'n' + {$$ = { type: 'VAR' }; } + | NUMBER + {$$ = { type: 'NUM', val: Number(yytext) }; } + ; |