PC Review


Reply
Thread Tools Rate Thread

C++ grammar for ANTLR & C# output

 
 
Rami
Guest
Posts: n/a
 
      30th Nov 2007
Hi,

I'm looking for ANTLR input file with C++ grammar which is configured for C#
output. Does anybody know where can I find it?


 
Reply With Quote
 
 
 
 
Ben Voigt [C++ MVP]
Guest
Posts: n/a
 
      3rd Dec 2007

"Rami" <(E-Mail Removed)> wrote in message news:fiphlr$o6b$(E-Mail Removed)...
> Hi,
>
> I'm looking for ANTLR input file with C++ grammar which is configured for
> C# output. Does anybody know where can I find it?


I think that the C++ grammar is too complicated for ANTLR syntax.


 
Reply With Quote
 
Arto Viitanen
Guest
Posts: n/a
 
      4th Dec 2007
Ben Voigt [C++ MVP] wrote:
> "Rami" <(E-Mail Removed)> wrote in message news:fiphlr$o6b$(E-Mail Removed)...
>> Hi,
>>
>> I'm looking for ANTLR input file with C++ grammar which is configured for
>> C# output. Does anybody know where can I find it?

>
> I think that the C++ grammar is too complicated for ANTLR syntax.
>
>


http://www.antlr.org/grammar/list thinks you are wrong: There is a C++
grammar made by David Wigg, but it uses C++ output. So, problem is C#,
not Antlr.

--
Arto Viitanen
 
Reply With Quote
 
Frans Bouma [C# MVP]
Guest
Posts: n/a
 
      4th Dec 2007
Arto Viitanen wrote:

> Ben Voigt [C++ MVP] wrote:
> >"Rami" <(E-Mail Removed)> wrote in message

> news:fiphlr$o6b$(E-Mail Removed)...
> > > Hi,
> > >
> > > I'm looking for ANTLR input file with C++ grammar which is
> > > configured for C# output. Does anybody know where can I find it?

> >
> > I think that the C++ grammar is too complicated for ANTLR syntax.

>
> http://www.antlr.org/grammar/list thinks you are wrong: There is a
> C++ grammar made by David Wigg, but it uses C++ output. So, problem
> is C#, not Antlr.


It's my understanding that the C++ syntaxis (similar to C) isn't
LR(n) compatible in 100% of the cases (so you WILL get shift/reduce
conflicts).

FB

--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
 
Reply With Quote
 
Arto Viitanen
Guest
Posts: n/a
 
      5th Dec 2007
Frans Bouma [C# MVP] wrote:

> It's my understanding that the C++ syntaxis (similar to C) isn't
> LR(n) compatible in 100% of the cases (so you WILL get shift/reduce
> conflicts).


But what does that have to do with ANTLR? It is LL parser, and actually
it is something they call LL(*). If I understood it right, the "*" can
be dynamic, and as long as the whole program.

--
Arto Viitanen
 
Reply With Quote
 
Frans Bouma [C# MVP]
Guest
Posts: n/a
 
      5th Dec 2007
Arto Viitanen wrote:

> Frans Bouma [C# MVP] wrote:
>
> > It's my understanding that the C++ syntaxis (similar to C) isn't
> > LR(n) compatible in 100% of the cases (so you WILL get shift/reduce
> > conflicts).

>
> But what does that have to do with ANTLR? It is LL parser, and
> actually it is something they call LL(*). If I understood it right,
> the "*" can be dynamic, and as long as the whole program.


isn't the LR in antLR stand for LR(n) parser generator? i.e. it
generates the action/goto shift/reduce tables for the generic parser
core?

It's been a while since I've looked at antlr, so I might be mistaken
in this. If AntLR is an LL parser generator, it can be done indeed.
Lookaheads longer than a couple of tokens aren't really recommended
btw.

FB

--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
 
Reply With Quote
 
Barry Kelly
Guest
Posts: n/a
 
      5th Dec 2007
Frans Bouma [C# MVP] wrote:

> isn't the LR in antLR stand for LR(n) parser generator? i.e. it
> generates the action/goto shift/reduce tables for the generic parser
> core?


No, antlr generates LL(n) recursive descent parsers, for any 'n' you
like.

> It's been a while since I've looked at antlr, so I might be mistaken
> in this. If AntLR is an LL parser generator, it can be done indeed.
> Lookaheads longer than a couple of tokens aren't really recommended
> btw.


Modeled as a state machine (typical for LR parsers), it results in
multiplicative (i.e. combinatorial) explosion; however, antlr uses
rather simpler if-then chaining, trading time for tractability.

-- Barry

--
http://barrkel.blogspot.com/
 
Reply With Quote
 
Barry Kelly
Guest
Posts: n/a
 
      5th Dec 2007
Frans Bouma [C# MVP] wrote:

> Arto Viitanen wrote:
>
> > Ben Voigt [C++ MVP] wrote:
> > >"Rami" <(E-Mail Removed)> wrote in message

> > news:fiphlr$o6b$(E-Mail Removed)...
> > > > Hi,
> > > >
> > > > I'm looking for ANTLR input file with C++ grammar which is
> > > > configured for C# output. Does anybody know where can I find it?
> > >
> > > I think that the C++ grammar is too complicated for ANTLR syntax.

> >
> > http://www.antlr.org/grammar/list thinks you are wrong: There is a
> > C++ grammar made by David Wigg, but it uses C++ output. So, problem
> > is C#, not Antlr.

>
> It's my understanding that the C++ syntaxis (similar to C) isn't
> LR(n) compatible in 100% of the cases (so you WILL get shift/reduce
> conflicts).


Yes, a fully validating C++ is not LR(n) or LL(n) for any n without
helping the lexer with information from the symbol table. Apart from
using lexer feedback, one can be more lenient in the syntax analysis and
use later semantic analysis to fix up the parse tree.

-- Barry

--
http://barrkel.blogspot.com/
 
Reply With Quote
 
Frans Bouma [C# MVP]
Guest
Posts: n/a
 
      6th Dec 2007
Barry Kelly wrote:

> Frans Bouma [C# MVP] wrote:
>
> > isn't the LR in antLR stand for LR(n) parser generator? i.e. it
> > generates the action/goto shift/reduce tables for the generic parser
> > core?

>
> No, antlr generates LL(n) recursive descent parsers, for any 'n' you
> like.


ah, thanks for clearing that up.

FB


--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bound Span control, limited output to data page, output truncated E W A L S H Microsoft Access 0 1st Apr 2007 06:12 AM
C# ANTLR can't parse the Java Code with Non-latin/Non-ascii characters Maulin Vasavada Microsoft C# .NET 0 12th Jul 2005 01:42 AM
[ANN] ANTLR 2.7.5 Release Candidate 2 is now available Kunle Odutola Microsoft C# .NET 0 9th Jan 2005 02:56 AM
[ANN] ANTLR 2.7.5 Release Candidate 2 is now available Kunle Odutola Microsoft VB .NET 0 9th Jan 2005 02:56 AM
[ANN] ANTLR 2.7.5 Release Candidate 1 is now available Kunle Odutola Microsoft C# .NET 0 22nd Dec 2004 09:47 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:38 AM.