%%
%% yecc file for postfix policy server
%%
%% This file cantains the leex definition for the postfix policy protocol.
%% ( see http://www.postfix.org/SMTPD_POLICY_README.html )
%% In short, the client sends a number of lines each containing a
%% name=value followed by an empty line. The server then reponds with
%% one name=value and an empty line.
%% 
%%

Nonterminals
request lines line lhs rhs words.

Terminals
eq word ws nl.

Rootsymbol request.
request -> lines nl : {request, '$1'}.

lines -> line : ['$1'].
lines -> lines line nl : '$1' ++ ['$2'].

line -> lhs eq rhs nl : {line, '$1', '$3'}.
line -> lhs eq nl : {line, '$1', undefined}.

lhs -> word : {lhs, '$1'}.

rhs -> words : {rhs, '$1'}.

words -> word : ['$1'].
words -> word ws words : ['$1', '$2'] ++ '$3'.

%%Erlang code.
