f



Converting BNF grammar to EBNF

Hi

I am a newbie with the parsing stuff, and I am trying to convert a BNF
grammar to an EBNF one. I have a lexer rule which states Set ::= Set1 -
Set2; I am using ANTLR v3.0 Beta 3 and unable to get how to convert
this into the ANTLR grammar. ANTLR just rejects the "-" operation on
sets. Please help!

Sandeep Gupta

0
sandy.pec (1)
8/9/2006 4:00:35 AM
comp.compilers 3310 articles. 1 followers. Post Follow

1 Replies
2509 Views

Similar Articles

[PageSpeed] 8

On 9 Aug 2006 00:00:35 -0400, "Scorpio" <sandy.pec@gmail.com> wrote:

>Hi
>
>I am a newbie with the parsing stuff, and I am trying to convert a BNF
>grammar to an EBNF one. I have a lexer rule which states Set ::= Set1 -
>Set2; I am using ANTLR v3.0 Beta 3 and unable to get how to convert
>this into the ANTLR grammar. ANTLR just rejects the "-" operation on
>sets. Please help!
>

It's been a while since I've done a parser with ANTLR so don't depend
on the syntax below.


Depending on what Set2 actually is, you may be able to use a syntactic
predicate like the following that proceeds only if the next token is
not from Set2.

   Set: ( ~Set2 )=> Set1;


There is also a way (but I forget how - check the manual) to
programmatically examine the token so you could write a semantic
predicate to check for and reject a token from Set2.  Semantic
predicates throw an exception if they fail which you will have to
catch.  Use an alternation like the following:

   Set: { /* code that returns false if token in Set2 */}?
        exception
          catch [SemanticException ex]
            { /* do nothing */}

      | Set1
      ;


Hope this helps.
George
0
George
8/11/2006 4:39:18 AM
Reply:

Similar Artilces:

(BNF) EBNF to BNF-grammar
Hello, I'm looking for a BNF grammar for converting EBNF to BNF. Any hints? Thanks and kind regards Udo "Udo" <WeikEngOff@aol.com> wrote: > I'm looking for a BNF grammar for converting EBNF to BNF. Any hints? Waite, Goos, "Compiler Construction", Appendix A, p. 383, gives some EBNF to BNF translation rules. With a somewhat different notation: 1. a (b) c := a x c, x: b. 2. a[b]c := a c | a(b)c. 3. a u+ c := a x c, x: u | x u. 4. a u* c := a[u+]c. 5. a || t := a(t a)*. where a, b, c are arbitrary RHS rules, x a unique non-terminal, u a ...

EBNF/BNF JOVIAL Grammar
Hi, I'm looking for JOVIAL BNFor EBNFgrammar, to write some lexical and syntaxical analyser. This is an old language and it seems very difficult to find information about it. do u know were i could find it ? even only a part... Any help will be very useful !! thanks a lot. [I'd be surprised if Jovial could be described in BNF easily. Someone asked the same question in 1990 and there's been no answer in the intervening 13 years. But see http://www.jovial.hill.af.mil/ -John] ...

Converting Simple BNF grammar to DTD or schema
I have a requirement to have an XML document that consists of an arbitrarily large expression. For simplicity's sake, assume I have the following grammar: expr => term rest term => ID relop ID rest => (conjunction term) | e conjunction => AND|OR relop => EQ|NE|GT|GE|LT|LE Is it possible to convert this grammar to a DTD or schema? I've tried the following DTD without success: <!ELEMENT expr (term,rest)> <!ELEMENT term (id,relop,id)> <!ELEMENT rest ((conjunction,term)|EMPTY)> <!ELEMENT conjunction (EMPTY)> <!ELEMENT id (#PCDATA)> <!ELE...

Convert unix c++ compiler flags to windows compiler flags?
I have these compiler flags in a CMakeList.txt file for a linux code: SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w -lX11 -Dcimg_use_xshm -lXext -Dcimg_use_xrandr -lXrandr -O3 -fpermissive -march=nocona -m64 -ffast-math -funroll-loops -finline-functions") Any ideas on who I convert those to windows (Visual Studio 2008) flags? In article <4a283fa0$0$90272$14726298@news.sunsite.dk>, mlt <asdf@asd.com> wrote: >I have these compiler flags in a CMakeList.txt file for a linux code: > -O3 -fpermissive -march=nocona -m64 -ffast-math -funroll-loops -finline-f...

Compile or not compile?
There's something that sometimes in while it bores me a little bit. How do I know if I need to compile a function/procedure or it will be able to compile "on fly". At the beginning I thought this was related to the paths idl "knew", but this happens for two functions/routines in the same directory. Can someone tell when a function can be runned without be compile? Nuno Oliveira wrote: > There's something that sometimes in while it bores me a little bit. How > do I know if I need to compile a function/procedure or it will be able > to compile &quo...

Compiled or not compiled
I need to distinguish between two situations: one when a Matlab function is run from Matlab command window and the other one when it is run in compiled mode. Any ideas how to do this? Thanks Tomy Duby "Tomy Duby" <tomy.duby@agilent.com> wrote in message news:idq8q8$85k$1@fred.mathworks.com... > I need to distinguish between two situations: one when a Matlab function > is run from Matlab command window and the other one when it is run in > compiled mode. > Any ideas how to do this? HELP ISDEPLOYED. -- Steve Lord slord@mathworks.com comp.s...

which compiler compiled?
Is there a way I can tell which compiler compiled an executable? I looked at the file with a hex editor and didn't see anything obvious. Lawrence "Lawrence" <just4me@nowhere.com> writes: > Is there a way I can tell which compiler compiled an executable? Yes with some compilers and some executable formats. E.g. on HP-UX for PA-RISC: $ aCC leak.C $ odump -compunit a.out ... 6 0 ANSI C++ leak.C /tmp ctcom options = -inst compiletime -diags 523 -inline_power 1 -longbranch 2 -unique_strings on -cachesize 256 B...

Compiling Compiler
Hi there, I need some advice/opinion of the experts out there regarding compilers. I have sun cc compiler that supports 64 bit environment. Now, I compile ACK using this compiler.This should give a compiler that supports 64bit environment. Since the output files are in Solaris format, I compile the ACK source *once again* using the just compiled ACK compiler so that I get Minix object and binary files. Now my questions is that does this 2nd version of ACK be able to produce true 64bit code? Sanky wrote: > Hi there, > > I need some advice/opinion of the experts out there regarding...

BNF grammar
I'm new to BNF and I'm not quite sure exactly what to do with this but I've given it a shot. I was wondering if someone could please check this over, and help me clean this up so it will be correct. Thanks The problem(question): In the language of an alien race, all words take the form of Blurbs. A Blurb is a Whoozit followed by one or more Whatzits. A Whoozit is the character x followed by zero or more y's. A Whatzit is a q followed by either a z or a d, followed by a Whoozit. Write a specification of this alien language as a BNF grammar. my stab at i...

To compile or not to compile
Is there some benefit in compiling the apache source yourself? -- //Points ------------------------------------------------------------ http://underthebed.homeip.net ...

To compile or not to compile
Is there some benefit in compiling the apache source yourself? -- //Points ------------------------------------------------------------ http://underthebed.homeip.net ...

compiling Qt .... compiling Qt ....compiling Qt.... compiling Qt
I got myself new kernel from kernel.org... make xconfig needs Qt (new system). So I got new Qt source this afternoon. It is still compiling.... Who said MS is bloat has not done this. What does Qt do? Dunno, how about xforms for xconfig? On Thu, 02 Feb 2006 19:18:09 +0000, Jan Panteltje wrote: > Dunno, how about xforms for xconfig? Why not curses based? menuform -- Hilsen/Regards Michael Rasmussen http://keyserver.veridis.com:11371/pks/lookup?op=get&search=0xE3E80917 On a sunny day (Thu, 02 Feb 2006 21:55:33 +0100) it happened Michael Rasmussen <mir@miras.or...

BNF grammar interpretation
[1] I have made an attemt to make an edif (LISP-like file) parser/translator. I want it to make universal. The file is a tree of identical elements. A ::= '(''plus' X Y')' 'plus' determines type of the expression, identifier is a terminal (string token) and X and Y are imperative (non-optional). I was trying to make a universal parser traveling through the tree and generating events to translator. As far as I've seen the imperative sub-expressions in edif grammar are usually defined like this: X ::= ( identifier | M | N ) M ::= '(''...

Parsers, grammars and BNF
Hey everyone, I want to write a BNF for a particular language. Can anyone recommend a good resource/guide for generating a BNF for a language? I'm just wondering is there a formula to follow before I start examining every possible statement! Cheers Tom Hey Tom, 2009/11/12 maniac <maniac_ie@yahoo.com>: > Hey everyone, > > I want to write a BNF for a particular language. > > Can anyone recommend a good resource/guide for generating a BNF for a > language? > > I'm just wondering is there a formula to follow before I start >...

Web resources about - Converting BNF grammar to EBNF - comp.compilers

Facebook Begins Converting Users To HTTPS
Are you willing to sacrifice a little bit of speed for a lot more safety? Facebook is asking that very question with its announcement that it ...

Facebook No Longer Converting Groups Into Pages
Back when Facebook first launched Facebook Pages, many businesses and brands who had built up substantial audiences in their Facebook Groups ...

Vert - simply converting for iPhone, iPad, and iPod touch on the iTunes App Store
Get Vert - simply converting on the App Store. See screenshots and ratings, and read customer reviews.

Converting SIM Card to Micro SIM Card - Flickr - Photo Sharing!
Place new Micro SIM into the iPhone SIM card tray

Ayaan Hirsi Ali on Converting Muslims to Christianity - YouTube
Complete video at: http://fora.tv/2010/07/29/Nomad_From_Islam_to_America_with_Ayaan_Hirsi_Ali Ayaan Hirsi Ali explains her support of missionary ...

Converting dry air to water: solution to Broken Hill's water crisis gains support
A one-man crusade by a Broken Hill resident to solve the historic town's water crisis by introducing air to water converters is gaining support. ...

Click go fears of converting print files
Is there a way to convert a print queue item to a .RTF or .PDF file? I like to save or email them. - The Sydney Morning Herald

Sudanese woman ordered to hang under sharia law for converting to Christianity gives birth
Khartoum, Sudan: A Christian Sudanese woman sentenced to hang for apostasy has given birth in jail, a Western diplomat said on Tuesday.

Imams warn against radicalism to Aboriginal inmates converting to Islam
The prison system has enlisted the help of ASIO to crack down on radicalisation behind bars amid revelations that Aboriginals are converting ...

Converting the world's companies one by one - The Science Show - ABC Radio National (Australian Broadcasting ...
Image: Trucks carrying logs make their way up a road in Jambi, Indonesia. A vast area of the Sumatran forest, and orangutan habitat, is being ...

Resources last updated: 1/24/2016 8:12:24 AM