context-free-grammar

Recognizing terminals in a CFG production previously not defined as tokens.

I'm making a generator of LL(1) parsers, my input is a CoCo/R language specification. I've already got a Scanner generator for that input. Suppose I've got the following specification: COMPILER 1 CHARACTERS digit="0123456789". TOKENS number = digit{digit}. decnumber = digit{digit}"."digit{digit}. PRODUCTIONS Expression = Term{"+"...

How do LL(*) parsers work?

I cannot find any complete description about LL(*) parser, such as ANTLR, on Internet. I'm wondering what is the difference between an LL(k) parser and an LL(*) one and why they can't support left-recusrive grammars despite their flexibility. ...

Parsing a context-free grammar in Python

What tools are available in Python to assist in parsing a context-free grammar? Of course it is possible to roll my own, but I am looking for a generic tool that can generate a parser for a given CFG. ...

What does =*> mean with regards to context free grammars?

I've been reading a couple books/online references about compiler theory, and keep seeing that particular operator coming up every once in a while (as seen here), specifically when the current topic is context free grammars. What does it mean? As well, how does it differ from =>? Explanations with examples distinguishing => from =*> wou...

"Arbitrary" context free grammars?

Long time admirer first time inquirer :) I'm working on a program which derives a deterministic finite-state automata from a context-free grammar, and the paper I have been assigned which explains how to do this keeps referring to "arbitrary probabilistic context-free grammars" but never defines the meaning of "arbitrary" in relation to...

Converting ambiguous grammar to unambiguous

I did not understand how a unambiguous grammar is derived from a ambiguous grammar? Consider the example on site: Example. How was the grammar derived is confusing to me. Can anyone please guide me ? ...

Variable and loops convertion from VB.NET to C++?

Is there any available tool for converting variable and loops declarations from VB.NET to C++? Thanks in advance ...

Is this an ambiguous grammar? How should I resolve it?

To preface this, my knowledge of this kind of stuff is puny. Anyways, I've been developing a context-free grammar to describe the structure of alegbraic expressions so I can teach myself how the CYK parsing algorithm works. I understand how such a structure can work with only infix algebraic expressions, but I cannot understand how to d...

Predicate Logic in Haskell

I've been using the following data structure for the representation of propositional logic in Haskell: data Prop = Pred String | Not Prop | And Prop Prop | Or Prop Prop | Impl Prop Prop | Equiv Prop Prop deriving (Eq, Ord) Any comments on this structure are welcome. However, now I want to extend ...

Help ... LL Grammar And Recursive descent parser

I'm using ANTRL and this is my some grammar which give error to me. statement : (name)( | BECOMES expression | LPAREN (expression (COMMA expression)*)? RPAREN | SHIFTLEFT name LPAREN (expression ( COMMA expression )*)? RPAREN ) | OUTPUT LPAREN expression ( COMMA expression)* RPAREN | IF expression THEN state...

Generating Context-Free-Grammar (TOC Basics)

The question states: Give a context-free grammar that generates the language A = {a^i b^j c^k | i=j or j=k where i,j,k >= 0} Is the grammar ambiguous? Why or why not? [Intro. to TOC Sipser 2.10] The book doesn't have too many good examples on how to generate a context free grammar merely from a description of the language. Should...

LALR Parser Generator Implementation Problem

Hi everyone! I'm currently trying to implement a LALR parser generator as described in "compilers principles techniques and tools" (also called "dragon book"). A lot already works. The parser generator is currently able to generate the full goto-graph. Example Grammar: S' --> S S --> C C ...

Follow sets for self-recursive rules

Alright, I'm trying to understand follow sets and I think I got it except for one thing: X -> a X X -> b X X -> epsilon Following the rules of this page, FOLLOW(X) should contains $, the end of file character (rule 1). Then, following rule 3, FOLLOW(X) contains everything of FOLLOW(X) which makes my brain melt. To me, intuitively, FO...

How can I determine if a language is context free or not?

How can I know whether the languages are context free or not? ...

Where can I find an official grammar for the PL/SQL programming language?

Where can I find an official grammar for the PL/SQL programming language? I see that the Antlr project has a user-contributed grammar, but I was hoping to find a more authoritative source. ...

Grammar production class implementation in C#

Grammar by definition contains productions, example of very simple grammar: E -> E + E E -> n I want to implement Grammar class in c#, but I'm not sure how to store productions, for example how to make difference between terminal and non-terminal symbol. i was thinking about: struct Production { String Left; // for example E...

Help with context-free grammar of lots of literal text with some special syntax

How do you make a context free grammar that analyzes mostly literal text (spaces, characters, symbols, etc.) while also looking for expressions of the form ${...} or $someCommand{...}? Note if it finds "I got $10 today", it should not do anything special with it. Is it possible? ...

Translating a right recursive grammar into Chomsky Normal Form

I am trying to do an exercise where I translate a grammar into Chomsky normal form. I understand how to do this in normal circumstances but this time the grammar I am working with is right recursive. (Technically the grammar is the answer to the previous question, so I might just have the wrong gamma.) I think I can do this by using a ...