Hi starboin, thank you for your suggestion!
I do dream of writing a parser myself one day, but, in fact I am just a beginner to perl.
Besides I don't have time for an overall study of perl currently.
So what I am doing is making the modification of the existing codes,
which turns to be a good way for me to study perl.
I post the simplified codes this time, hope it wont take much time for you to go through.
Thanks a lot!!!

Parser.xs
/* Mine: */ #define SCPARSE_C #include "scparse.h" /* Perl */ #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include "ppport.h" #/* self->read (filename) */ int _read_xs (CLASS, filename, strip_autos) SV *CLASS char *filename int strip_autos PROTOTYPE: $$$ CODE: { static int/*bool*/ in_parser = 0; if (!SvROK(CLASS)) { in_parser = 0; croak ("Parser::read() not called as class member"); } if (!filename) { in_parser = 0; croak ("Parser::read() filename=> parameter not passed"); } if (in_parser) { croak ("Parser::read() called recursively"); } in_parser = 1; scparse_init (CLASS, filename, strip_autos); if (!sclex_open (filename)) { in_parser = 0; croak ("Parser::read() file not found"); } scgrammerparse(); fclose (sclexin); /* Emit final tokens */ scparser_EmitPrefix (); if (scParserState.errors) { in_parser = 0; croak ("Parser::read() detected parse errors"); } in_parser = 0; RETVAL = 1; } OUTPUT: RETVAL
Paser.pm
#!/usr/local/bin/perl package Parser; use strict; require Exporter; require DynaLoader; our @ISA = qw(DynaLoader Exporter); our %EXPORT_TAGS = ( 'all' => [ qw() ] ); our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); our @EXPORT = qw(); our $VERSION = '1.261'; bootstrap Parser $VERSION; sub new { my $class = shift; $class = ref $class if ref $class; my $self = { strip_autos=>0, @_}; bless $self, $class; return $self; } sub read { my $self = shift; my %param = (@_); if (!-r $param{filename}) { print "%Error: file not found: $param{ +filename}, stopped";} $self->_read_xs($param{filename}, $param{strip_autos}||$self->{str +ip_autos}); }
TrialParser.pl
#! /usr/local/bin/perl use ExtUtils::testlib; package Trialparser; use Parser; @ISA = qw(Parser); package main; my $sp = Trialparser->new(); $sp->read (filename =>'ExParse.sp');
Can't locate auto/Trialparser/class.al in @INC (@INC contains: /cygdrive/d/parser/blib/arch /cygdrive/d/parser/blib/lib /usr/lib/perl5/5.8/cygwin /usr/lib/perl5/5.8 /usr/lib/perl5/site_perl/5.8/cygwin /usr/lib/perl5/site_perl/5.8 /usr/lib/perl5/vendor_perl/5.8/cygwin /usr/lib/perl5/vendor_perl/5.8 .) at /cygdrive/d/parser/blib/lib/Parser.pm line 51
Error comes from Parser.pm in Line 51:
$self->_read_xs($param{filename}, $param{strip_autos}||$self->{strip_autos});

In reply to Re^4: An error in using XS by ming_322
in thread An error in using XS by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.