Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8644411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:17:14+00:00 2026-06-12T12:17:14+00:00

Assuming that i need to tokenize and parse only multiline comments, how will i

  • 0

Assuming that i need to tokenize and parse only multiline comments, how will i do that using Parse::Lex. When using flex-bison, the default action for any pattern in the rules section of the lex file used to be ‘skip’.

%%
.*    ;
%%

How to do this here ?

[EDIT] Well, i tried that, i’m still missing something – here is my code – and result. Where have i gone wrong ??

my simplified lex file:

use Parse::Lex;
use Regexp::Common;
use YParser;
my $lexer;
my @token = (
qw|esp:TA abcdefgh|,
qw(esp:REST .|\n),
);
Parse::Lex->trace;
Parse::Lex->exclusive('esp');
$lexer = Parse::Lex->new(@token);
$lexer->from(\*STDIN);
$lexer->skip(qr! [ \t]+ | $RE{balanced}{-begin=>'/*'}{-end=>'*/'} !xms);
$lexer->start('esp');

my $j = YParser->new();
$j->YYParse(yylex => \&lex);

sub lex {
    my $token = $lexer->next;
    return ('', undef) if $lexer->eoi;
    if ($token->name eq 'TA' || $token->name eq 'REST') {
        return ($token->name, {LINENO => $lexer->line, TEXT => $token->text});
    }
}

my simplified grammar file

% token TA REST

%%

Program:  Element
          | Program Element
;
Element:  TA
          | REST
;

%%

Input file:

abcdefgh
/*sdf*/

Result:
perl lexfile.pl < inputfile

Trace is ON in class Parse::Lex
Can't call method "name" on an undefined value at qnlex.pl line 26, <STDIN> line 1.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T12:17:15+00:00Added an answer on June 12, 2026 at 12:17 pm

    Well, i figured this out 🙂 Very simple – all i have to do is make the lex get the next token when encountering tokens i want to skip. Below is code to skip passing the token ‘REST’ to the parser.

    sub lex {
        my $token;
        NEXTTOKEN:
        $token = $lexer->next;
        return ('', undef) if $lexer->eoi;
        if ($token->name eq 'TA') {
            return ($token->name, {LINENO => $lexer->line, TEXT => $token->text});
        }
        elsif ($token->name eq 'REST') {
            goto NEXTTOKEN;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Rails 3 to create a project that will need a model called
Assuming that the larger a database gets, the longer it will take to SELECT
I am working on a web based application that will need to store usernames
Assuming that I have this: enum { A = 0x2E, B = 0x23, C
Assuming that parsing the equation would not be a problem, how can I make
assuming that I know the PID of a process and want to do a
Assuming that I have a CronTriggerBean similar to <bean id=midMonthCronTrigger class=org.springframework.scheduling.quartz.CronTriggerBean> <property name=jobDetail ref=reminderJobDetail
Assuming that best practices have been followed when designing a new database, how does
Assuming that I have a typedef declared in my .h file as such: typedef
Assuming that I know there is a git-daemon running at git://git.mycompany.com , how can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.