comp.lang.ada
 help / color / mirror / Atom feed
From: per.nordlow@gmail.com
Subject: Stack Overflow when Pyparsing Ada 2005 Scoped Identifiers using Reference Manual Grammar
Date: Thu, 21 Mar 2013 01:04:46 -0700 (PDT)
Date: 2013-03-21T01:04:46-07:00	[thread overview]
Message-ID: <bb6c17a7-1971-4e81-83fd-87da78b54d6e@googlegroups.com> (raw)

I'm currently implementing an Ada 2005 parser using Pyparsing and the reference manual grammar rules. We need this in order to analyze and transform parts of our aging Ada-codebase to C/C++.

Most things work.

However, one little annoying problem remains:

The grammar rule name when parsing scoped identifiers (rule selected_component) such as the expression "Global_Types.Integer2" fails because it is part of a left-associative grammar rule cycle.

Pyparsing infinite recursion and Python spits out maximum recursion depth exceeded.

I believe the problem is caused either by the fact that

•the associativity of the grammar rule selected_component is right-to-left. I've search the reference manual of Pyparsing but haven't found anything relevant. Should we treat dot (.) as an operator with right-to-left associativity or can we solve it throught extensions and restructurings of the grammar rules?

•or by the fact that there is no check in Pyparsing infinite recursions. I believe this wouldn't be too hard to implement. Use a map from currently active rules (functions) to source position/offset (getTokensEndLoc()) and always fail a rule if the current source input position/offset equals the position related to the rule just entered.

The problem also seems closely related to

"Need help in parsing part of python grammar": http://pyparsing.wikispaces.com/message/view/home/51617848

which unfortunately doesn't have answers yet.

Also see this thread

http://stackoverflow.com/questions/15438015/stack-overflow-when-pyparsing-ada-2005-scoped-identifiers-using-reference-manual?noredirect=1#comment22014663_15438015

Thanks in advance,
Per Nordlöw



             reply	other threads:[~2013-03-21  8:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-21  8:04 per.nordlow [this message]
2013-03-21 12:55 ` Stack Overflow when Pyparsing Ada 2005 Scoped Identifiers using Reference Manual Grammar Lucretia
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox