C++ grammar for ANTLR & C# output

  • Thread starter Thread starter Rami
  • Start date Start date
R

Rami

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?
 
Rami said:
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.
 
Arto said:
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#)
------------------------------------------------------------------------
 
Frans said:
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 said:
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#)
------------------------------------------------------------------------
 
Frans said:
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
 
Frans said:
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
 
Barry said:
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#)
------------------------------------------------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top