Questions tagged [formal-languages]

The study of formal languages concerns the definition, description (generation) and parsing (recognition) of sets of strings over finite sets of symbols. The set of all binary representations of integers, the set of all palindromes over the lowercase Latin alphabet, and the set of all binary representations of Turing machines which do not accept themselves are examples of formal languages.

381 questions
160
votes
6 answers

Why can't C++ be parsed with a LR(1) parser?

I was reading about parsers and parser generators and found this statement in wikipedia's LR parsing -page: Many programming languages can be parsed using some variation of an LR parser. One notable exception is C++. Why is it so? What particular…
Cheery
  • 24,645
  • 16
  • 59
  • 83
92
votes
2 answers

What is a regular language?

I'm trying to understand the concept of languages levels (regular, context free, context sensitive, etc.). I can look this up easily, but all explanations I find are a load of symbols and talk about sets. I have two questions: Can you describe in…
43
votes
4 answers

Why do we need prefix, postfix notation

I know how each of them can be converted to one another but never really understood what their applications are. The usual infix operation is quite readable, but where does it fail which led to inception of prefix and postfix notation
34
votes
2 answers

Which contemporary computer languages are LL(1)?

(I am spending the holiday time on some language theory. Excuse me if this is a naive question.) According to here: LL grammars, particularly LL(1) grammars, are of great practical interest, as parsers for these grammars are easy to construct,…
smwikipedia
  • 61,609
  • 92
  • 309
  • 482
28
votes
5 answers

Where can I find a formal grammar for MATLAB?

I would like to write a lexer generator to convert a basic subset of the MATLAB language to C#, C++, etc. To help me do this, I would like to find a document containing the formal grammar for MATLAB. Having spent a bit of time investigating this, it…
Dave Maff
  • 798
  • 8
  • 12
27
votes
3 answers

What kind of formal languages can modern regex engines parse?

Here on SO people sometimes say something like "you cannot parse X with regular expressions, because X is not a regular language". From my understanding however, modern regular expressions engines can match more than just regular languages in…
georg
  • 211,518
  • 52
  • 313
  • 390
22
votes
2 answers

Left-Linear and Right-Linear Grammars

I need help with constructing a left-linear and right-linear grammar for the languages below? a) (0+1)*00(0+1)* b) 0*(1(0+1))* c) (((01+10)*11)*00)* For a) I have the following: Left-linear S --> B00 | S11 B --> B0|B1|011 Right-linear S --> 00B…
19
votes
3 answers

Is JavaScript a Context Free Language?

This article on how browsers work explains how CSS is context free, while HTML is not. But what about JavaScript, is JavaScript context free? I am learning about CFG and formal proofs, but am a long way away from understanding how to figure this…
Lance
  • 75,200
  • 93
  • 289
  • 503
18
votes
3 answers

chomsky hierarchy and programming languages

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…
16
votes
1 answer

Are regular haskell algebraic data types equivalent to context free grammars? What about GADTS?

The syntax for algebraic data types is very similar to the syntax of Backus–Naur Form, which is used to describe context-free grammars. That got me thinking, if we think of the Haskell type checker as a parser for a language, represented as an…
Nathan BeDell
  • 2,263
  • 1
  • 14
  • 25
16
votes
4 answers

Tips for creating "Context Free Grammar"

I am new to CFG's, Can someone give me tips in creating CFG that generates some language For example L = {am bn | m >= n} What I got is: So -> a | aSo | aS1 | e S1 -> b | bS1 | e but I think this area is wrong, because there is a chance…
user1988365
14
votes
3 answers

What is the difference between recursive and recursively enumerable languages

I was wondering what the difference between recursive and recursively enumerable languages is in terms of halting and Turing Machines. I know that recursively enumerable languages are a subset of recursive languages but I'm not sure about the…
14
votes
2 answers

Is L = {a^n b^m | n>m} a regular or irregular language?

How can I prove if L = {a^n b^m | n>m} is a regular or irregular language?
Jerald James Capao
  • 175
  • 1
  • 1
  • 7
14
votes
4 answers

To make sure: Pumping lemma for infinite regular languages only?

So this is not about the pumping lemma and how it works, it's about a pre-condition. Everywhere in the net you can read, that regular languages must pass the pumping lemma, but noweher anybody talks about finite languages, which actually are a part…
12
votes
2 answers

How to convert NFA to Regular Expression

I knew that converting a regular expression to a NFA, there is a algorithm. But I was wondering if there is a algorithm to convert a NFA to regular expression. If there is, what is it? And if there isn't, I am also wondering if all NFA can convert…
formatjam
  • 347
  • 1
  • 3
  • 13
1
2 3
25 26