Definite Clause Grammar - Non-context-free Grammars

Non-context-free Grammars

In pure Prolog, normal DCG rules with no extra arguments on the functors, such as the previous example, can only express context-free grammars; there is only one argument on the left side of the production. However, context-sensitive grammars can also be expressed with DCGs, by providing extra arguments, such as in the following example:

s --> a(N), b(N), c(N). a(0) --> . a(M) -->, a(N), {M is N + 1}. b(0) --> . b(M) -->, b(N), {M is N + 1}. c(0) --> . c(M) -->, c(N), {M is N + 1}.

This set of DCG rules describes the grammar which generates the language that consists of strings of the form .

s --> symbols(Sem,a), symbols(Sem,b), symbols(Sem,c). symbols(end,_) --> . symbols(s(Sem),S) -->, symbols(Sem,S).

This set of DCG rules describes the grammar which generates the language that consists of strings of the form, by structurally representing

Read more about this topic:  Definite Clause Grammar

Famous quotes containing the word grammars:

    The violent illiteracies of the graffiti, the clenched silence of the adolescent, the nonsense cries from the stage-happening, are resolutely strategic. The insurgent and the freak-out have broken off discourse with a cultural system which they despise as a cruel, antiquated fraud. They will not bandy words with it. Accept, even momentarily, the conventions of literate linguistic exchange, and you are caught in the net of the old values, of the grammars that can condescend or enslave.
    George Steiner (b. 1929)