Questions tagged [dcg-semicontext]

Use this tag with Prolog when using DCG and using a semicontext.

References:

9 questions
6
votes
3 answers

Extension to CFG, what is it?

Consider the following extension to context-free grammars that permits rules to have in the left-hand side, one (or more) terminal on the right side of the non-terminal. That is, rules of the form: A b -> ... The right-hand side may be anything,…
false
  • 10,264
  • 13
  • 101
  • 209
4
votes
1 answer

Context sensitive generation in prolog

I am interested in generating elements of a context sensitive language as described by Chomsky, as described in Chomsky Classification of Grammars under the section "Type - 1 Grammar". (Basically, similar to a standard context-free grammar, but…
4
votes
2 answers

breadth first on binary tree - using Semicontext notation

I would like to compute list being bfs order on binary tree. Moreover, it should work in second side - for list it find tree. Can you give me some hint, so far I have used something like that, of course it doesn't work... bfs(nil) --> []. bfs(t(X,…
user6023611
4
votes
2 answers

Right-hand Context Notation[DCG]

in this site, I found a part that explains how to build Right-hand Context Notation using DCG A → ε | a A Head, [T_1,...,T_n] --> Body. someone help me figure out this method by example and illustrate its benefits to parse context-free grammar
Ans Piter
  • 573
  • 1
  • 5
  • 17
3
votes
1 answer

Applying semicontext for passing additional arguments

This is a follow-on question from an earlier question from Mat's answer Starting with this e([number(0)] , t1 , Uc0 , Uc0, Bc0 , Bc0) --> []. e([number(1)] , t2 , Uc0 , Uc0, Bc0 , Bc0) -->…
Guy Coder
  • 24,501
  • 8
  • 71
  • 136
2
votes
2 answers

Threading state/context in DCG while parsing text

How to pass State (and change it when I need) around while parsing text !? https://www.metalevel.at/prolog/dcg the example is doing counting.. Don't know how I'm supposed to pass the initial State. Do I have to do it as call-parameter or as a first…
sten
  • 7,028
  • 9
  • 41
  • 63
2
votes
2 answers

Translation to DCG Semicontext not working - follow on

As a follow up to this question which poses the problem Return count of items in a list but if two identical items are next to each other then don't increment the count. This code is the closest I came to solving this with DCG and…
Guy Coder
  • 24,501
  • 8
  • 71
  • 136
1
vote
1 answer

Translation to DCG Semicontext not working

Since this question uses list, I wanted to solve it using DCG. In the process I realized that semicontext could be used. (DCG Primer) The original problem is to return count of items in a list but if two identical items are next to each other then…
Guy Coder
  • 24,501
  • 8
  • 71
  • 136
1
vote
1 answer

Dcg state implementation of algorithm

The distance between a long sequence and a short sequence, is the minimum distance between the short sequence and any subsequence of the long sequence that is the same length as the short sequence. The distance I am using is I think the Manhattan…
user27815
  • 4,767
  • 14
  • 28