:- module(_,_).

%% * Parsing: making the pairs of arguments implicit -> DCGs
%    -------------------------------------------------------
%    Definite CLause Grammars (DCGs)

:- use_package(dcg).
% :- use_package(sr/bfall).

myphrase --> article, spaces, noun, spaces, verb.
% Translates to:
% myphrase(X,CV) :- article(X,CA), spaces(CA,CS1), noun(CS1,CN),
%                   spaces(CN,CS2), verb(CS2,CV).

article --> "a".  % Translates to: article( "a"   || X, X).
article --> "the".

spaces --> " ".
spaces --> " ", spaces.

noun --> "car".
noun --> "plane".

verb --> "flies".
verb --> "drives".

% Try:
% ?- set_prolog_flag(write_strings, on).
% ?- myphrase("the plane flies", []).
% Or, using the phrase/2 built-in:
% ?- phrase(myphrase,"the plane flies").
% ?- myphrase("the plane", []).
% ?- myphrase(S, []).

% Try also uncommenting :- use_pakage(sr/bfall).
% above and, again:
% ?- myphrase(S,[]).
