grammar

Grammar for Java's annotations

Is there a BNF or EBNF that describes the grammar for Java's annotations? ...

I need to find an automaton for this language

Please help me find a grammar or automaton to decide the following language: anbncn where n≥1 ...

problem antlrworks code too large

In Antlrworks I get this error: [18:21:03] Checking Grammar Grammar.g... [18:21:26] Grammar.java:12: code too large [18:21:26] public static final String[] tokenNames = new String[] { [18:21:26] ^ [18:21:26] 1 error Using instead the generated code in a Java project works normally. What can be...

Is it easier to write a recursive-descent parser using an EBNF or a BNF?

I've got a BNF and EBNF for a grammar. The BNF is obviously more verbose. I have a fairly good idea as far as using the BNF to build a recursive-descent parser; there are many resources for this. I am having trouble finding resources to convert an EBNF to a recursive-descent parser. Is this because it's more difficult? I recall from my C...

Lexer antlr3 token problem

Can I construct a token ENDPLUS: '+' (options (greedy = false;):.) * '+' ; being considered by the lexer only if it is preceded by a token PREwithout including in ENDPLUS? PRE: '<<' ; Thanks. ...

ANTLR grammar from bison

Hello, I'm trying to translate a grammar from bison to ANTLR. The grammar itself is pretty simple in bison but I cannot find a simple way for doing this. Grammar in bison: expr = expr or expr | expr and expr | (expr) Any hints/links/pointers are welcome. Thanks, Iulian ...

Help with Boost Grammar

I have been using the following win32 console code to try to parse a B Machine Grammar embedded within C++ using Boost Spirit grammar template. I am a relatively new Boost user. The code compiles, but when I run the .exe file produced by VC++2008, the program partially parses the input file. I believe the problem is with my grammar defin...

Island grammar antlr3...

What are and how to use the "island grammar" in antlr3? ...

BNF vs EBNF vs ABNF: which to choose?

I want to come up with a language syntax. I have read a bit about these three, and can't really see anything that one can do that another can't. Is there any reason to use one over another? Or is it just a matter of preference? ...

How to correctly formalize the command line usage of GNU/Linux commands?

I'd like to write down a BNF-like formal grammar for describing the command line usage of some GNU/Linux tools. For example I can describe the usage of the cat command as: (cat-command) : 'cat' (arguments-list) (arguments-list) : (argument) (arguments-list) : (arguments-list) (argument) (argument) : (file) The problem is I can't write...

Grammar that is LR(1) but not LL(1)

This might look like a basic question to some of you but I expect intelligent replies here. Why can't a LR(1) grammar with left recursion or the LR(1) grammar that is not left factored be LL(1)? ...

Context free grammer

Hello. I have this problem where i need to convert the following CFG to CFG in CNF. S-> ABa A-> aab B-> Ac I know the steps are as follows. Remove epsilon transitions - Done remove unit productions convert to CNF by: introduce a new non terminal for each term replace terminals in the productions rules with the new nonterminal i...

Convert regular expression to CFG

How can I convert some regular language to its equivalent Context Free Grammar? Whether the DFA corresponding to that regular expression is required to be constructed or is there some rule for the above conversion? For example, considering the following regular expression 01+10(11)* How can I describe the grammar corresponding to...

Removing left recursion

The following grammar has left recursion E= E+T|T T= T*F|F F= a|b|c How to remove it? Is there any general procedure for it? ...

LL(1) cannot be ambiguous

How can it be shown that no LL(1) grammar can be ambiguous? I know what is ambiguous grammar but could not prove the above theorem/lemma. ...

Regular Expression

Ohh! this regular expression thing is eating my brain up. I have been reading it from Introduction to Automata Theory, Languages and Computer by Hopcroft, Motwani and Ullman. I have solved a few exercises too but could not solve the following even after trying for almost one hr. The problem is to write a regular expression that defines...

Data Quality Check - SQL Server

I am trying to find a good mechanism where I can check whether the data being entered by a group of people is grammatically correct, has correct spellings, etc, etc. I also would like to compute words per minute and accuracy. Is there any process to do this so that I do not have to re-invent the wheel? Thanks in advance. ...

Bison: Optional tokens in a single rule.

Hi there .. i'm using GNU Bison 2.4.2 to write a grammar for a new language i'm working on and i have a question. When i specify a rule, let's say : statement : T_CLASS T_IDENT '{' T_CLASS_MEMBERS '}' { // create a node for the statement ... } If i have a variation on the rule, for instance statement : T_CLASS T_IDENT T_E...

Re: Help with Boost Grammar

I have redesigned and extended the grammar I asked about earlier as shown below: // BIFAnalyser.cpp : Defines the entry point for the console application. // // /*============================================================================= Copyright (c) Temitope Jos Onunkun 2010 http://www.dcs.kcl.ac.uk/pg/onun/ Use, mod...

How to transform a production to LL(1) for a list separated by a semicolon?

Hi, I'm reading this introductory book on parsing (which is pretty good btw) and one of the exercice is to "build a parser for your favorite language." Since I don't want to die today, I thought I could do a parser for something relatively simple, ie a simplified CSS. Note: This book teach you how to write a LL(1) parser using the recur...