Questions tagged [context-free-language]

In formal language theory, a context-free language (CFL) is a language generated by some context-free grammar (CFG). The set of regular languages is a subset of the set of context-free languages.

183 questions
0
votes
1 answer

Why are deterministic context free languages (DCFL) not closed under UNION operation and context free languages are closed under union?

Does that mean only non deterministic context free languages are closed under union? Then why is it mentioned in almost all text books and sites that CFLs in general are closed under Union? An intuitive explanation will suffice. Detailed proof not…
0
votes
0 answers

Describe Context-free Language

As context-free grammar is S --> aSbS|b|epsilon How can I describe the language it accepted? I can find the language in certain length, but I can't describe it.
Jennifer Q
  • 257
  • 3
  • 12
0
votes
1 answer

Solution to a joke related to EBNF

What do you think, what is the solution to the following problem related to EBNF? The following message was seen on a bumper sticker: Stinks Syntax. What is the joke? So far this I got to my mind: r1 ::= in | yn r2 ::= ks | x Stinks Syntax ::= St r1…
Vlad
  • 2,739
  • 7
  • 49
  • 100
0
votes
1 answer

Write EBNF form for a year/month/day

I want to find solution to the next problem, but I need to write EBNF of time in two formats, year-month-day and month-day-year to see the differences: Identify one advantage of writing dates as a structured-integer in the form: year, month, day…
Vlad
  • 2,739
  • 7
  • 49
  • 100
0
votes
1 answer

How to show the following grammar is ambiguous?

I have the following grammar defined: S -> A|B, A -> aAb | ab, B -> aBb | epsilon; After working for some time, I still couldn't find a string to construct a distinctive parse tree to show that this grammar is ambiguous. Like: aaabbb,abab,etc. It…
0
votes
1 answer

Proving language is context-free with pumping lemma

I've got a test coming up in using the pumping lemma to prove whether or not a language is context free. I'm trying to work through some practice problems and things aren't going so great... The practice problem is: For a) through j), prove whether…
0
votes
2 answers

How can I check that the language of one context-free grammar is a subset of a second context-free grammar?

Could you explain me, how can I check, that the language of first context-free grammar (G1) is a subset of the language of second context-free grammar (G2). G1 and G2 are two LL(1) grammars with identical alphabets: {a, b, c, d, f} Production rules…
0
votes
1 answer

Context free grammar syntax

I'm trying to clarify the following about context-free grammar: If I've got the following, S->T0T If there are two possible values for T ie. T-> 1T | 1 Do I have to use the same value when substituting both Ts, like so: T0T becomes (1T)0(1T) =>…
0
votes
1 answer

Algorithm of checking a grammar against another grammar in ll(1)

I need an algorithm that checks if the language of G1 is a subset of G2's language or not. (Assume G1 and G2 are two LL(1) grammars with identical alphabets whose production rules are either of the form A-->aB or A-->a , and "a" is a…
0
votes
1 answer

Give a grammar for the following language

Give a grammar for the following language {0^n w 1^n | n>=0 w is in {0,1}* and |w|=n} Attempt at solution: S--> 0S1|R R--> 0R|1R|empty not sure how to guarantee the length of r is the same as the number of 0's or 1's.
0
votes
1 answer

Generating CFG for a Language

Consider the language {anbmcp | n <= p OR m <= p} , create a CFG for this language. I have started this with S -> aA | aB, but am unsure how I should go about defining A or B. The "OR" seems quite difficult to incorporate into the language's…
DennisKRQ
  • 175
  • 1
  • 6
0
votes
2 answers

Design a context free grammar language where length of a = double length of b

I would like to know if someone can help me designing a context free grammar for a language where { w | |w|a=2|w|b } for example w=aab , aaaabb , aaaaaabbb ,baa , aba , aabbaaaba ... S-> aab | baa | aba | SS | abSa | baSa | aaSb | bSaa would not…
Zok
  • 355
  • 2
  • 15
0
votes
1 answer

Parsing JSON RFC Grammar

I am learning to build parsers and thought maybe I should start with a simple one such as JSON. I was looking at the JSON grammar published in this RFC document. The JSON grammar shown there looks like what's shown below. What kind of notation is…
hyde
  • 2,525
  • 4
  • 27
  • 49
0
votes
1 answer

LL(1) grammar interpretation

How do I interpret this grammar? I can't understand why some words are bold. If I was writing a parse tree/table for this, would I include the bold words? I'm trying to figure out if the grammar in the pic is LL(1), but do not understand how to…
o.o
  • 3,563
  • 9
  • 42
  • 71
0
votes
1 answer

Find out if language is context-free or not

If I have {a^n b^n c^n | n > 0} \sum = {a,b,c}, how can I prove if it's a context-free language? I looked here: Determine if a language is context free, but doesn't make much sense to me. I believe it is if I do ::= |abc ::=…
o.o
  • 3,563
  • 9
  • 42
  • 71