chomsky-hierarchy

Chomsky Language Types

眉间皱痕 提交于 2021-02-05 16:43:05
问题 I'm trying to understand the four different Chomsky language types but the definitions that I have found don't really mean anything to me. I know type 0 is free grammar, type 1 is context sensitive, type 2 is context free whilst type 3 is regular. So, could someone please explain this and put it into context, thanks. 回答1: A language is the set of words that belong to that language. Many times, however, instead of listing each and every word in the language, it is enough to specify the set of

Is Rust's syntactical grammar context-free or context-sensitive?

家住魔仙堡 提交于 2019-12-23 12:54:51
问题 The syntactical grammar of hardly any programming language is regular, as they allow arbitrarily deeply nested parenthesis. Rust does, too: let x = ((((())))); But is Rust's syntactical grammar at least context-free? If not, what element makes the grammar context-sensitive? Or is the grammar even recursively enumerable, like C++'s syntactical grammar? Related : Is Rust's lexical grammar regular, context-free or context-sensitive? 回答1: Rust includes a macro processor, whose operation is highly

Example of Non-Linear, UnAmbiguous and Non-Deterministic CFL?

可紊 提交于 2019-12-17 06:51:42
问题 In the Chomsky classification of formal languages, I need some examples of Non-Linear, Unambiguous and also Non-Deterministic Context-Free-Language(N-CFL)? Linear Language : For which Linear grammar is possible( ⊆ CFG) e.g. L 1 = {a n b n | n ≥ 0 } Deterministic Context Free Language(D-CFG) : For which Deterministic Push-Down-Automata(D-PDA) is possible e.g. L 2 = {a n b n c m | n ≥ 0, m ≥ 0 } L 2 is unambiguous. A CF grammar that is not linear is nonlinear. L nl = {w: n a (w) = n b (w)} is

Example of Non-Linear, UnAmbiguous and Non-Deterministic CFL?

别等时光非礼了梦想. 提交于 2019-12-17 06:51:18
问题 In the Chomsky classification of formal languages, I need some examples of Non-Linear, Unambiguous and also Non-Deterministic Context-Free-Language(N-CFL)? Linear Language : For which Linear grammar is possible( ⊆ CFG) e.g. L 1 = {a n b n | n ≥ 0 } Deterministic Context Free Language(D-CFG) : For which Deterministic Push-Down-Automata(D-PDA) is possible e.g. L 2 = {a n b n c m | n ≥ 0, m ≥ 0 } L 2 is unambiguous. A CF grammar that is not linear is nonlinear. L nl = {w: n a (w) = n b (w)} is

Is Rust's lexical grammar regular, context-free or context-sensitive?

允我心安 提交于 2019-12-12 10:54:13
问题 The lexical grammar of most programming languages is fairly non-expressive in order to quickly lex it. I'm not sure what category Rust's lexical grammar belongs to. Most of it seems regular, probably with the exception of raw string literals: let s = r##"Hi lovely "\" and "#", welcome to Rust"##; println!("{}", s); Which prints: Hi lovely "\" and "#", welcome to Rust As we can add arbitrarily many # , it seems like it can't be regular, right? But is the grammar at least context-free? Or is

Regexp parse type-3 grammar

两盒软妹~` 提交于 2019-12-11 14:39:33
问题 Reading Chomsky hierarchy ... ... I know regexp can't parse type-2 grammars (context-free grammars), and also type-1 and type-0. Can regular expressions parse/catch ALL type-3 grammars (regular grammars)? 回答1: Yes, provided they support alternation, concatenation, and the Kleene star. This is the case for regexes of the PCRE (Perl/Java/JavaScript/PHP/...) type: alternation is implemented by ((...)|(...)) , concatenation by (...)(...) , and the Kleene star by (...)* . (There are a few other

What kind of language is SQL?

你。 提交于 2019-12-07 13:02:32
问题 Is SQL a context free language or some other type of language? 回答1: According to https://stackoverflow.com/a/31265136 SQL is not a regular language. The short explanation is that each select query looks like SELECT x FROM y WHERE z and y can be another select query itself, so it cannot be simulated with finite-state machine. As mentioned before, there are some CFGs for SQL standarts in Backus–Naur Form, thereby SQL is nonregular context free language. 回答2: @aquinas wrote: Do you mean is SQL

What kind of language is SQL?

老子叫甜甜 提交于 2019-12-05 18:37:35
Is SQL a context free language or some other type of language? SGP According to https://stackoverflow.com/a/31265136 SQL is not a regular language. The short explanation is that each select query looks like SELECT x FROM y WHERE z and y can be another select query itself, so it cannot be simulated with finite-state machine. As mentioned before, there are some CFGs for SQL standarts in Backus–Naur Form , thereby SQL is nonregular context free language. @aquinas wrote: Do you mean is SQL also regular? CFG's encompass regular languages. So, they aren't mutually exclusive. To answer your question

chomsky hierarchy and programming languages

最后都变了- 提交于 2019-12-03 07:14:54
问题 I'm trying to learn some aspects of the Chomsky Hierarchy which are related to programming languages, and i still have to read the Dragon Book. I've read that most programming languages can be parsed as a context free grammar (CFG). In term of computational power, it equals the one of a pushdown non deterministic automaton. Am I right? If it's true, then how could a CFG hold an unrestricted grammar (UG), which is turing complete? I'm asking because, even if programming languages are described

Is there a standard C++ grammar?

浪尽此生 提交于 2019-11-28 16:52:27
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, etc. Any links pointing me in the right direction would be helpful. By category, I mean taken from here . James McNellis Yes, it does. The grammar is described in detail throughout the standard and is summarized in Appendix A: Grammar Summary (it's Appendix A in both the C++03 standard and the C++0x final committee draft). You can purchase the C++03 standard or you can download the C++0x FCD (it's