| www.ClassicTW.com http://classictw.com/ |
|
| Adding Lexer parsing http://classictw.com/viewtopic.php?f=15&t=33821 |
Page 1 of 1 |
| Author: | Tweety [ Thu Mar 07, 2013 6:57 pm ] |
| Post subject: | 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}\[KYou recover \[1;36m{NN_INTEGER}\[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. |
|
| Author: | Tweety [ Thu Mar 07, 2013 9:31 pm ] |
| Post subject: | 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 |
|
| Author: | Mongoose [ Thu Mar 07, 2013 10:12 pm ] |
| Post subject: | 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? |
|
| Author: | Tweety [ Thu Mar 07, 2013 11:00 pm ] |
| Post subject: | Re: Adding Lexer parsing |
no. no luck yet. must be something with the expression. not sure really right now. |
|
| Page 1 of 1 | All times are UTC - 5 hours |
| Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |
|