in reply to Re^2: Parse grammar via RecDescent parser
in thread Parse grammar via RecDescent parser

guessing...

file_exists: 'file(' filename ')' { $return = "-e $item{ 'filename' }; push @somepackagename +::savedfilenames, $item{ 'filename' } }

Then outside the parser, retrieve the array as @somepackagename::savedfilenames

Replies are listed 'Best First'.
Re^4: Parse grammar via RecDescent parser
by the_dark_lord (Novice) on May 17, 2016 at 15:12 UTC
    I had thought of that but the file names are to be stored in a non-static object. Providing a static method for a accessing a non-static object is not a good design. Perl allows this but it wont be allowed for other languages such as Java.

      If you're creating Perl code in your parser, why do you worry about non-Perl languages?

      If you need to have a non-static but singular object, maybe you want to implement the Singleton pattern in your language of choice. Or maybe you want to provide the target container using Dependency Injection.

      Or maybe you can help us help you better by telling us more about your overarching goal. I have the impression that you try to achieve many things from a single and oddly specific approach, and that approach seems to be a bad fit for the solutions you try to get from it.

        Hi The library has already been implemented and anyways singleton is not a good design pattern.

        So I might have to go with the static method approach. I cannot explain the whole framework because it would be very arduous and difficult to understand as there are many components.

        I might have to go with the static method approach.