Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

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!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1025094]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2018-02-25 11:30 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (312 votes). Check out past polls.