context-free-grammar Questions

3

Solved

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:...
Bespread asked 22/8, 2012 at 11:20

2

Solved

Can a LR(1) parser parse a grammar of this type? S -> SA | A A -> aSb | ab I'm trying to write a Java program that implements this type of parser, but I only get the right results on a gra...
Bales asked 30/1, 2014 at 16:25

1

Solved

I'd like to define an unordered set of values using an Extended Backus-Naur Form (EBNF) context free grammar. It's easy to define an unordered list of values in EBNF, for example: value = 'A' | 'B...

2

Solved

I've seen this algorithm one should be able to use to remove all left recursion. Yet I'm running into problems with this particular grammar: A -> Cd B -> Ce C -> A | B | f Whatever I tr...
Simferopol asked 14/4, 2013 at 14:2

1

Solved

Can anyone explain to me how FIRST and FOLLOW should be used in LL(1) grammar? I understand that they are used for syntax table construction, but I don't understand how.
Selfsatisfaction asked 1/12, 2013 at 20:58

1

Solved

Making artificial LR(k) grammars for k > 1 is easy: Input: A1 B x Input: A2 B y (introduce reduce-reduce conflict for terminal a) A1 : a A2 : a B : b b b ... b (terminal b occurs k-1 times) Howe...
Discriminate asked 26/11, 2013 at 2:18

1

Does anyone know of a program that uses a GA to perform grammar induction/inference, I've read tonnes of research papers and articles on this stuff like Lankhorst and De Pauw but I can't find any i...

5

Solved

Does the standard specify the official C++ grammar? I searched, but did not find it anywhere. Also, I wish to read a bit about C++ grammar in detail, like which category of grammars it falls in, ...

1

Solved

How can a formal context free grammar be generated for the following language: {ai bjck | i != j or j != k} I have following productions but can't understand it: S->AX | YC unequal b’s c...
Wenzel asked 20/10, 2013 at 5:32

1

Solved

What algorithm do you use to enumerate the strings generated by a context-free grammar? It seems doable when there is no recursion, but I can't figure out how to do it in the general case, which m...
Celestyna asked 30/6, 2013 at 6:8

1

On the web, there is a lot of examples showing how to construct parsing tables for a context-free grammar from first/follow sets for LL(1) parser. But I haven't found anything useful related to k>...
Wieren asked 25/1, 2012 at 10:17

1

Solved

I was trying to implement a LL(1) top-down parser for a calculator language. It only allows us to sum, subtract, divide and multiply numbers. No parentheses. S -> A A -> B + A | B - A | B...
Marital asked 6/5, 2013 at 19:12

1

Solved

I'm trying to get my head around context free grammars and I think I'm close. What is baffling me is this one question (I'm doing practise questions as I have an exam in a month's time): I've come...
Patricio asked 13/4, 2013 at 15:5

2

Solved

I've been reading: "Tips for creating Context free grammar" post for learning purposes and I nearly understand the concept, but I don't quite understand the following. If we have: L = {am bn |...
Catch asked 13/4, 2013 at 2:12

1

Solved

How can someone validate if a string is part of a context free Grammar? Not just virtually, but build an algorithm for it? Given a context free grammar with rules such as V-> v1v2 v1->1 | 1v1 v...

1

Solved

I just took my midterm but couldn't answer this question. Can someone please give a couple of examples of the language and construct a grammar for the language or at least show me how i wi...

1

I'm trying to prove the following: If G is a Context Free Grammar in the Chomsky Normal Form, then for any string w belongs L(G) of length n ≥ 1, it requires exactly 2n-1 steps to make any de...

1

We are learning about ambiguity in class, and the following grammar was given as an example of an ambiguous grammar. I just am not seeing how it is ambiguous. Is there a set pattern or method peopl...
Chanson asked 2/3, 2013 at 15:25

1

Solved

I have the following grammar: S → a S b S | b S a S | ε Since I'm trying to write a small compiler for it, I'd like to make it LL(1). I see that there seems to be a FIRST/FOLLOW conflict here, an...

3

I'm not really very clear on the concept of ambiguity in context free grammars. If anybody could help me out and explain the concept or provide a good resource I'd greatly appreciate it.
Bluebeard asked 17/5, 2011 at 18:30

2

Solved

Basically, I'm trying to syntax highlight the following piece of coffeescript code the way I want it. Explanation of the syntax of coffeescript functions can be found here. nameHere = (tstamp, moo...
Gothicize asked 3/2, 2013 at 0:36

2

Solved

I'm trying to add 2 things to my grammar: Unary minus sign, i.e. '-', and Parentheses Here's my grammar so far: <comp> ::= <expr> | <comp> <op0> <expr> <expr&g...

2

Solved

I used to think C++ was the "weird" one with all the ambiguities with < and >, but after trying to implement a parser I think I found an example which breaks just about every language that us...
Renayrenckens asked 19/1, 2013 at 8:29

3

Solved

Given: I have no idea what the accepted language is. From looking at it you can get several end results: 1.) bb 2.) ab(a,b) 3.) bbab(a, b) 4.) bbaaa

1

I am having difficulties understanding the principle of lookahead in LR(1) - items. How do I compute the lookahead sets? Say for an example that I have the following grammar: S -> AB A -> a...
Haemophiliac asked 19/11, 2012 at 18:10

© 2022 - 2024 — McMap. All rights reserved.