chomsky hierarchy in plain english

Maybe you get a better understanding if you remember the automata generating these languages. Regular languages are generated by regular automata. They have only have a finit knowledge of the past (their compute memory has limits) so everytime you have a language with suffixes depending on prefixes (palindrome language) this can not be done with … Read more

Why is bottom-up parsing more common than top-down parsing?

If you choose a powerful parser generator, you can code your grammar without worrying about peculiar properties. (LA)LR means you don’t have to worry about left recursion, one less headache. GLR means you don’t have to worry about local ambiguity or lookahead. And the bottom-up parsers tend to be pretty efficient. So, once you’ve paid … Read more

Is there a standard C++ grammar?

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 document n3092 on that page). To answer … Read more

What are the differences between PEGs and CFGs?

A CFG grammar is non-deterministic, meaning that some input could result in two or more possible parse-trees. Though most CFG-based parser-generators have restrictions on the determinability of the grammar. It will give a warning or error if it has two or more choices. A PEG grammar is deterministic, meaning that any input can only be … Read more

What is the difference between LALR and LR parsing? [duplicate]

At a high level, the difference between LR(0), LALR(1), and LR(1) is the following: An LALR(1) parser is an “upgraded” version of an LR(0) parser that keeps track of more precise information to disambiguate the grammar. An LR(1) parser is a significantly more powerful parser that keeps track of even more precise information than an … Read more

Context-free grammars versus context-sensitive grammars?

An important detail here is that grammars do not accept strings; they generate strings. Grammars are descriptions of languages that provide a means for generating all possible strings contained in the language. In order to tell if a particular string is contained in the language, you would use a recognizer, some sort of automaton that … Read more

Can this language be described by a non-ambiguous BNF grammar?

It’s not always easy (or even possible) to demonstrate that a grammar is ambiguous, but if there is a short ambiguous sentence, then it can be found with brute-force enumeration, which is what I believe that tool does. And the output is revealing; the shortest ambiguous sentence is the empty string. So it remains only … Read more

Is D’s grammar really context-free?

Being context free is first a property of generative grammars. It means that what a non-terminal can generate will not depend on the context in which the non-terminal appears (in non context-free generative grammar, the very notion of “string generated by a given non-terminal” is in general difficult to define). This doesn’t prevent the same … Read more

The recognizing power of “modern” regexes

Pattern Recursion With recursive patterns, you have a form of recursive descent matching. This is fine for a variety of problems, but once you want to actually do recursive descent parsing, you need to insert capture groups here and there, and it is awkward to recover the full parse structure in this way. Damian Conway’s … Read more

What programming languages are context-free?

What programming languages are context-free? […] My gut tells me that functional languages might be context-free […] The short version: There are hardly any real-world programming languages that are context-free in any meaning of the word. Whether a language is context-free or not has nothing to do with it being functional. It is simply a … Read more

techhipbettruvabetnorabahisbahis forumu