View unanswered posts | View active topics It is currently Thu Dec 25, 2025 6:22 pm



Reply to topic  [ 4 posts ] 
 Adding Lexer parsing 
Author Message
Boo! inc.

Joined: Fri Jan 04, 2002 3:00 am
Posts: 221
Location: Canada
Unread post Adding Lexer parsing
I've been trying to see if i can add some parsing to weaponm.

so i added some code to different files in the hope that it will work. I was trying to add a catch for You Recover 22 of your turns. message and update my turn variable in the database which would subsequently i would think update the status panel unless i have to explicitly fire off a event.

DataLexer.jplex
Code:
<Rule expr="{LD}&#27;\[KYou recover &#27;\[1;36m{NN_INTEGER}&#27;\[0;35m of your turns\." event="recoverTurns"/>


DataParser.java
Code:
// Updating turns as events happen
   @Override
   public void recoverTurns(CharSequence seq, int off, int len) {
      you.setTurns(you.getTurns()+ParserUtils.findInteger(seq, off, len));      
   }


DataEventAdapter.java
Code:
    @Override
    public void recoverTurns(CharSequence seq, int off, int len) {
    }


DataEventListener.java
Code:
public void recoverTurns(CharSequence seq, int off, int len);


DataEventLogger.java
Code:
@Override
    public void recoverTurns(CharSequence seq, int off, int len) {
        logger.debug("recoverTurns: " + seq.subSequence(off, off + len));
    }


I then made sure i exported JPlex to a jar with its libraries like you mentioned and ran it to produce new .gz files which also looks like it modified DataLexer.java

but I don't get anything firing in the console. Did i do too many steps? or miss anything? I've never used regular expressions before, so maybe that is where i'm going wrong. i just tried to copy the one above which pulls "You have 33 turns this Stardate." but then also noticed that it doesn't trigger anything in the console either.


Thu Mar 07, 2013 6:57 pm
Profile
Boo! inc.

Joined: Fri Jan 04, 2002 3:00 am
Posts: 221
Location: Canada
Unread post Re: Adding Lexer parsing
After playing some more. it looks like the only code i have to implement is into DataParser.java to implement the required methods after jplex is run on DataLexer.jplex

it seems to rebuild DataEventAdapter, DataEventListener, DataEventLogger and DataLexer

now to wait for turns to see if the expression i put in works haha


Thu Mar 07, 2013 9:31 pm
Profile
Commander
User avatar

Joined: Mon Oct 29, 2001 3:00 am
Posts: 1096
Location: Tucson, AZ
Unread post Re: Adding Lexer parsing
Right... if you add a rule to the .jplex file and run JPlex, it will update everything except the parser. Your code looks right. Did it work?

_________________
Suddenly you're Busted!


Thu Mar 07, 2013 10:12 pm
Profile WWW
Boo! inc.

Joined: Fri Jan 04, 2002 3:00 am
Posts: 221
Location: Canada
Unread post Re: Adding Lexer parsing
no. no luck yet. must be something with the expression. not sure really right now.


Thu Mar 07, 2013 11:00 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 24 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by wSTSoftware.