Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Specialty database API.

by rjt (Deacon)
on Mar 23, 2013 at 23:33 UTC ( #1025094=note: print w/ replies, xml ) Need Help??


in reply to Specialty database API.

For the parsing of your language, Parse::RecDescent is usually my go-to for things like this. If your language is not that complex, you may be able to get by with regexes or somesuch, but if you think it's likely to get more complex in the future, the investment into a stronger parser might be worthwhile.

As for accessing someone else's lexical variables in the way you describe, I'm not sure you can, at least not with pure Perl runtime. Have a look at perlguts for a little more information on what's going on behind the scenes. This can be a very dangerous road to go down that can open up many unforeseen consequences, such as what happens with tied variables, especially given the desired asynchronous behavior you've described.

It won't exactly be trivial, but writing a Perl source filter will probably be the most straightforward way to accomplish what you want to do. If you've never worked with filters before, the link has some helpful examples, but the short version is that your custom filter would be given the text of the Perl source code you are running, upon which you can perform any text transformations you like, before Perl parses and compiles the source. So, you could conceivably detect and parse your "DBC" source from within the Perl source, and then convert it into those lower-level API calls you mentioned, before Perl sees it.

Handling the asynchronous dependencies (such as $value being fetched on line 123, and needed again on line 126), will probably require you to maintain some sort of dependency tree. I predict debugging will be fun!


Comment on Re: Specialty database API.
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1025094]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (10)
As of 2014-07-30 06:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (229 votes), past polls