Questions tagged [context-sensitive-grammar]

A context-sensitive grammar is a type of grammar that generates precisely the context-sensitive languages.

Context-sensitive grammars are grammars where each rule has the form

xAy -> xwy

Where A is a nonterminal and x, y, and z are strings of terminals and nonterminals.

56 questions
3
votes
1 answer

Difference between Context-sensitive grammar and Context-free grammar

Possible Duplicate: Context-sensitive grammar and Context-free grammar In my textbook, here is the explain of these two terms : Context Sensitive Grammar: grammar can have productions of the form w1 → w2, where w1 = lAr and w2 = lwr, where A…
hqt
  • 29,632
  • 51
  • 171
  • 250
2
votes
2 answers

Context sensitive language with non deterministic turing machine

how can i show a language is context sensitive with a non deterministic turing machine? i know that a language that is accepted by a Linear bound automaton (LBA ) is a context -sensitive language. And a LBA is a non-deterministic turing machine. Any…
2
votes
2 answers

Matching wwR ("acddca”) using regular expressions example in C#

I'm a complete noob at Regular Expressions. I've been reading through them but I still don't quite get them, like I don't even know what the '-' sign means. Can we do an example one, and walk me through it possibly? How would we do this…
2
votes
1 answer

formal method to do semantic analysis in compiler

I know there is a formalism called attribute grammar,and a non-formalism method called syntax-directed translation,but the first is inefficient and the latter one is difficult to automate. Does there exist other recent formalism about semantic…
2
votes
1 answer

Construct grammar given the following language {a^n b^m | n,m = 0,1,2,...,n <= 2m}

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 will go about it? Also how to write grammar for L: L =…
2
votes
1 answer

Which languages are context-sensitive?

I'm learning "Compiler Theory", it says most of languages used "deterministic context-free grammar". I wonder is there any language use "context-sensitive grammar"? Update: I asked someone, he said that c++ and ruby has some context-sensitive…
Freewind
  • 193,756
  • 157
  • 432
  • 708
1
vote
0 answers

Is there a parsing algorithm for languages generated by context-sensitive grammars?

Details I am already familiar with Chart Parsing using Earley Parsers. I am however, unsure about whether there even is a meta-syntax like Backus-Naur Form (BNF) that can represent a Context-Sensitive Grammar (CSG). Since parsing using a Linear…
1
vote
1 answer

Context-sensitive Grammar for a^nb^nc^n

Is the following CSG for a^nb^nc^n correct? S->aSbC|abc Cb->bC C->c If not please explain why?
1
vote
1 answer

How to deal with large alphabets in BNF?

Given a language defined as: Any pair of matching symbols is a valid string. E.g. 00, 55, qq, YY And a large alphabet of non-terminal symbols (let's say 4,294,967,296 of them)... How would you define a BNF grammar to express the language?…
1
vote
1 answer

BNF (EBNF) to describe table format with optional columns

Im trying the define a grammar that can be used to describe the following type of…
1
vote
2 answers

How best to write this xtext grammar

I am using Xtext, and need suggestions on the following two problems. Problem #1 Lets say I have three rules a, b and c. And I want to allow any sequence of these rules, except that b and c should appear only once. How best to write such a…
Waqas Ilyas
  • 3,116
  • 1
  • 17
  • 27
1
vote
1 answer

Chomsky hierarchy - Type-1 context-sensitive languages

I try to unterstand the Chomsky hierarchy with the different levels. I checked some examples and here is one I don't really understand. Maybe someone knows why this one is not a context-sensitive language: S → aA A → aA | ε B → bA
1
vote
1 answer

Chomsky languages: how to recognize them?

I have a problem with the recognition of languages. Given a certain language, for example ancb2n, n > 0, how do I determine quickly what type belongs according Chomsky? My idea was to determine the grammar that generates it and then up to the…
1
vote
1 answer

Context Sensitive Grammar for a specific language

Hey i have been stuck on this problem for a few days now and even going through sample problems in my textbook as well as sample solutions i cant figure out how to make this grammar work. Give a Grammar for this language L: L = { a^n^2 : n ≥ 0 } I…
Fragmatist
  • 31
  • 4
1
vote
1 answer

Context-sensitive grammar

I'm looking for a context-sensitive grammar that describes the following language: L = { ww | w ∈ {a,b}*, |w| ≥ 1}
I've got problems with the fact that no rules such as X -> ε are allowed and therefore I can't place any nonterminal indicating…