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 8684715
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:22:31+00:00 2026-06-12T22:22:31+00:00

I am doing a academic work that I need to use parser and lexer

  • 0

I am doing a academic work that I need to use parser and lexer generator for php.
I searched on the internet and I found this

The problem is create the grammar and plex file.
For example:

<?php
class blah {
/*!lex2php
%input $this->data
%counter $this->N
%token $this->token
%value $this->value
%line $this->line
variable = @/?:([a-zA-Z0-9_]+)/?@
*/
/*!lex2php
variable {$a = 1;}
*/
}
?>

Someone can explain me that code please?

  • 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-12T22:22:32+00:00Added an answer on June 12, 2026 at 10:22 pm

    The first comment block is used for declarations. All the % declaration are mostly for internal use, and not very relevant at this stage.
    The variable = @/?:([a-zA-Z0-9_]+)/?@ is interesting though. It defines a nonterminal symbol variable, defined by the regex @/?:([a-zA-Z0-9_]+)/?@.

    If you generate your lexer using this plex file and feed it something like this:

    234lksdf lskdjf324 kl234jd
    

    The tokenstream would be as follows:

    token: variable
    value: 234lksdf 
    
    token: variable
    value: lskdjf324 
    
    token: variable
    value: kl234jd
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is an academic question (I'm not necessarily planning on doing it) but I
I'm doing a desktop academic project one of the requirment of this project is
doing this in AppDelegate: viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil]; Is there any problem
Doing some work in javascript I have a multidimensional made up in this format
This question is purely academic, because I'd never dream of doing this in real
I'm currently doing an academic benchmark, TPC-H, and I have some big tables that
Quite an academic question this - I've had it remarked that a class I've
Doing the getting started of Sinatra. I get this error: ./sinatra.rb:5: undefined method `get'
Doing the below will reproduce my problem: New WPF Project Add ListView Name the
I'm doing an academic project which focus on providing some enhanced LBS services for

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.