Re: parser using perl



I am not a compler expert, but if I all I am interested in few
productions out of
many productions, I can setup by scanner to generate tokens pertaining to
interesting productions and ignore the rest. As I said, I am not a
compiler expert.
So, I could be understating the problem ..

I will have a look at the parser library. Thanks ...

Regards

On Mon, Mar 31, 2008 at 8:16 PM, Chas. Owens <chas.owens@xxxxxxxxx> wrote:

On Mon, Mar 31, 2008 at 10:36 AM, Sharan Basappa
<sharan.basappa@xxxxxxxxx> wrote:
> Hi,
>
> I am trying to extract information from a file that follows the syntax
> of a high level language (something like C++)
> The script just needs to understand a very minuscule portion of this
> language to do this. It does not have to
> know the complete high level language. I just wanted to know any
> modules are available within perl that makes
> this job easier. I feel it is possible to do the complete work in
> perl, but I might be wrong. Especially around the
> recursion that languages support. The other option I have is to use a
> public domain parser like Bison and parse
> the input, build some data structure that perl can lookup and do the processing.
>
> I would like to know experience of people on this forum ...
>
> Regards


Take a look at Parse::RecDescent*. In general, it doesn't matter if
you want to work with a small piece of a language or the whole
language, you still need to implement a parser for the whole language.
You can get an eighty or ninety percent solution without a full
parser, but there will always be problems.

* http://search.cpan.org/dist/Parse-RecDescent/lib/Parse/RecDescent.pm

--
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

.



Relevant Pages

  • RE: Writing a compiler compiler
    ... eventually generate a parser for a dynamic language. ... grammar used in the experiments has some 292+ productions, ... Part of what makes writing grammars for such languages more manageable is ...
    (comp.compilers)
  • Re: About parsers, and parsing
    ... action and goto tables which conforms the lrparser. ... considering that each character is one of your input tokens. ... So I get `sum', process it through the automata or lexical analyzer, ... table so I can know `sum' was a known keyword for this language. ...
    (comp.unix.programmer)
  • Re: OFF-TOPIC:: Why Lisp is not my favorite programming language
    ... The interpreter would be written in C. ... It is always possible to beat any interpreted language for speed using ... >at me for calling lisp a parsing language... ... I would write a parser to do so. ...
    (comp.lang.python)
  • Re: Some clarification on "Pre-Parsers" and other bits
    ... the "C" you are talking about is a language. ... would be confusing) that is a parser for the C language. ... A typical compiler ... the input is syntactically correct. ...
    (alt.lang.asm)
  • Parsing syntax (was: Why dont people like lisp?)
    ... > Python is a domain specific language where the domain is ... then it really still isn't a big deal; a parser ... "John's going to Mary's house." ...
    (comp.lang.lisp)