context-sensitive-grammar


Examples of Non Context free language in C language?

拟墨画扇 提交于 2019-12-30 12:12:40
问题 What are examples of non - context free languages in C language ? How the following non-CFL exists in C language ? a) L1 = {wcw|w is {a,b}*} b) L2 = {a^n b^m c^n d^m| n,m >=1} 回答1: The question is clumsily worded, so I'm reading between the lines, here. Still, it's a common homework/study question. The various ambiguities [1] in the C grammar as normally presented do not render the language non-context-free. (Indeed, they don't even render the grammars non-context-free.) The general rule "if

Is C++ context-free or context-sensitive?

[亡魂溺海] 提交于 2019-12-28 03:05:29
问题 I often hear claims that C++ is a context-sensitive language. Take the following example: a b(c); Is this a variable definition or a function declaration? That depends on the meaning of the symbol c . If c is a variable , then a b(c); defines a variable named b of type a . It is directly initialized with c . But if c is a type , then a b(c); declares a function named b that takes a c and returns an a . If you look up the definition of context-free languages, it will basically tell you that

formal method to do semantic analysis in compiler

痞子三分冷 提交于 2019-12-23 02:41:20
问题 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 analysis? 回答1: OP suggests "attribute grammars" are inefficient, and syntax-directed translation is difficult to automate. I offer a proof-point showing otherwise, name a few other semantic systems, and suggest how they might be integrated, below. Our

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

一曲冷凌霜 提交于 2019-12-18 12:42:55
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 6 years ago . 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

formal method to do semantic analysis in compiler

可紊 提交于 2019-12-08 14:11:37
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 analysis? OP suggests "attribute grammars" are inefficient, and syntax-directed translation is difficult to automate. I offer a proof-point showing otherwise, name a few other semantic systems, and suggest how they might be integrated, below. Our DMS Software Reengineering Toolkit supports both of these activities and more. It provides parsers for full

chomsky hierarchy in plain english

China☆狼群 提交于 2019-12-02 17:30:35
I'm trying to find a plain (i.e. non-formal) explanation of the 4 levels of formal grammars (unrestricted, context-sensitive, context-free, regular) as set out by Chomsky. It's been an age since I studied formal grammars, and the various definitions are now confusing for me to visualize. To be clear, I'm not looking for the formal definitions you'll find everywhere (e.g. here and here -- I can google as well as anyone else), or really even formal definitions of any sort. Instead, what I was hoping to find was clean and simple explanations that don't sacrifice clarity for the sake of

Parsing Context Sensitive Language

吃可爱长大的小学妹 提交于 2019-11-30 18:52:20
i am reading the Definitive ANTLR reference by Terence Parr, where he says: Semantic predicates are a powerful means of recognizing context-sensitive language structures by allowing runtime information to drive recognition But the examples in the book are very simple. What i need to know is: can ANTLR parse context-sensitive rules like: xAy --> xBy If ANTLR can't parse these rules, is there is another tool that deals with context-sensitive grammars? ANTLR parses only grammars which are LL(*). It can't parse using grammars for full context-sensitive languages such as the example you provided. I

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

我的未来我决定 提交于 2019-11-30 07:46:13
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 = {a n b m | n,m = 0,1,2,..., n <= 2m } ? Thanks in advance. Grijesh Chauhan How to write grammar for formal language? Before read my this answer you should read first: Tips for creating Context free grammars . Grammar for {a n b m | n,m = 0,1,2,..., n <= 2m } What is you language L = {a n b m | n,m = 0,1,2,..., n <= 2m } description? Language description :

Parsing Context Sensitive Language

五迷三道 提交于 2019-11-30 02:37:43
问题 i am reading the Definitive ANTLR reference by Terence Parr, where he says: Semantic predicates are a powerful means of recognizing context-sensitive language structures by allowing runtime information to drive recognition But the examples in the book are very simple. What i need to know is: can ANTLR parse context-sensitive rules like: xAy --> xBy If ANTLR can't parse these rules, is there is another tool that deals with context-sensitive grammars? 回答1: ANTLR parses only grammars which are

Context-free grammars versus context-sensitive grammars?

怎甘沉沦 提交于 2019-11-29 19:14:24
Can someone explain to me why grammars [context-free grammar and context-sensitive grammar] of this kind accepts a String? What I know is Context-free grammar is a formal grammar in which every production(rewrite) rule is a form of V→w Where V is a single nonterminal symbol and w is a string of terminals and/or non-terminals. w can be empty Context-sensitive grammar is a formal grammar in which left-hand sides and right hand sides of any production (rewrite) rules may be surrounded by a context of terminal and nonterminal symbols. But how can i explain why these grammar accepts a String? An

工具导航Map