Enum with extra ',' at the last item

Bug #1001417 reported by Daisuke Niizumi
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pyclibrary
Fix Committed
Undecided
Unassigned

Bug Description

Hi, firstly thanks for sharing C parser, it helps me a lot.

By the way I got problem with the delimitedList and resolved here.
So I want to share my problem (would be common with people) and solution.

My C code has this kind of enum which have ',' with the last item.
By using pyparsing's delimitedList by default, it denies the last one.
Just resulted in not parsed by the CParser.

enum {
    enum1=2,
 enum2=0, enum3,
    enum4,
 enum5,
};

My solution:

I modified buildParser() so that it accepts extra ','.

Original code was
> self.enumType << Keyword('enum') + (Optional(ident)('name') + lbrace + Group(delimitedList(enumVarDecl))('members') + rbrace | ident('name'))

Modified to
> self.enumType << Keyword('enum') + (Optional(ident)('name') + lbrace + Group(delimitedList(enumVarDecl))('members') + Optional(",") + rbrace | ident('name'))

Related branches

Revision history for this message
lcampagn (luke-campagnola) wrote :

Thanks; fixed!

Changed in pyclibrary:
status: New → Fix Committed
raju (raju131187)
Changed in pyclibrary:
status: Fix Committed → Confirmed
status: Confirmed → New
status: New → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.