Parsec question

Eray Ozkural erayo@cs.bilkent.edu.tr
Wed, 10 Jul 2002 18:29:09 +0300


Hi there,

I'm hacking together a small parser for a subset of C++.

I'm in trouble with left recursion as you may guess.

What is the best way to write a parser for the part of grammar below in 
Parsec?

   Declarator
      -> Name
      -> PtrOper Declarator
      -> Declarator '(' ArgDeclarationList ')' [CvQualifierList]
      -> Declarator '[' [ConstantExp] ']'
      -> '(' Declarator ')'

Here [X] denotes an optional non-terminal X, and all symbols starting with a 
capital letter are non-terminals.

The remedies I thought of were using chainl or eliminating left recursion in 
the grammar. What do you think should be done in such a case?

Regards,

-- 
Eray Ozkural <erayo@bilkent.edu.tr>
Comp. Sci. Dept., Bilkent University, Ankara
www: http://www.cs.bilkent.edu.tr/~erayo
GPG public key fingerprint: 360C 852F 88B0 A745 F31B  EA0F 7C07 AE16 874D 539C