[antlr-interest] easypal....
Mohammed Ibrahim
snouto at gmail.com
Fri Sep 7 08:43:41 PDT 2007
hello professors .
i built a grammar , i built a demo of it in a java program and i ran it from console window ,
i wrote something like that
c:\>Mainclass trans_id:"875hjhy64786jbhryr"
Mainclass is my final java program that must parse the first input from the user which is the above parameter to the console java program and here is my grammar
grammar easypal_proto;
stat returns [String datas] : r+;
r returns [String outputs]: e=FULL_TRANS_PRODUCTION{outputs = $e.text;};
// $<Test Production
FULL_TRANS_PRODUCTION returns [String value]
: PRODUCTION_TRANS_ID (DELIMA? e=NORMAL_TEXT{value=$e.text;} DELIMA?) NEWLINE*;
// $>
// $<Protocol Headers
PRODUCTION_TRANS_ID
: (LBL_TRANS COLON);
// $>
//===================================================================
// $<Compounds
LEFT_TRIBRACKETS
: '>';
RIGHT_TRIBRACKETS
: '<';
NORMAL_TEXT
: (CRYPTO_CHUNK|LETTER|INT)+
;
CRYPTO_CHUNK
: ('~'|'!'|'@'|'$'|'%'|'^'|'&'|'*'|'('|')'|'_'|'-'
|';'|','|'.')+;
LETTER : ('A'..'Z'|'a'..'z')+;
INT : '0'..'9'+;
DELIMA : '"';
COLON : ':';
NEWLINE : '\r'? '\n';
WS : (SPACE)+ {skip();};
SPACE : '\u0020';
// $>
//==============================================================================
//Commands
// $<Commands
COM_HELLO
: 'HELLO'|'hello';
COM_AUTHENTICATE
: 'AUTHENTICATE'|'authenticate';
COM_SUCCESS
: 'SUCCESS'|'success';
COM_FAILURE
: 'FAILURE'|'failure';
COM_FRIENDLIST
: 'FRIENDLIST'|'friendlist';
COM_MESSAGE
: 'MESSAGE'|'message';
COM_QUERY
: 'QUERY'|'query';
COM_BYE : 'BYE'|'bye';
COM_JOIN: 'JOIN'|'join';
COM_CHANGE
: 'CHANGE'|'change';
COM_SIGNOFF
: 'SIGNOFF'|'signoff';
// $>
//==============================================================================
// Protocol Labels
// $<Label Constants
LBL_TRANS
: 'trans_id'|'TRANS_ID';
LBL_CLIENT_MODEL
: 'CLIENT_MODEL'|'client_model';
LBL_PUBLIC_KY
: 'public_ky'|'PUBLIC_KY';
LBL_ENCRYPTION_ID
: 'ENCRYPTION_ID'|'encryption_id';
LBL_SERVER_MODEL
: 'SERVER_MODEL'|'server_model';
LBL_USERS
: 'USERS'|'users';
LBL_USER: 'USER'|'user';
LBL_ONBOARD
: 'ONBOARD'|'onboard';
LBL_REASON_TEXT
: 'REASON_TEXT'|'reason_text';
LBL_TO : 'TO'|'to';
LBL_FROM: 'FROM'|'from';
LBL_CONTENT_TYPE
: 'content_type'|'CONTENT_TYPE';
LBL_FNAME
: 'FNAME'|'fname';
LBL_FSIZE
: 'FSIZE'|'fsize';
LBL_FCOLOR
: 'FCOLOR'|'fcolor';
LBL_BODY: 'BODY'|'body';
LBL_TYPE: 'TYPE'|'type';
LBL_DATA: 'DATA'|'data';
LBL_FILE: 'FILE'|'file';
LBL_SIZE: 'SIZE'|'size';
LBL_SPECS
: 'SPECS'|'specs';
LBL_STATUSCODE
: 'STATUS_CODE'|'status_code';
LBL_ROOM_ID
: 'ROOM_ID'|'room_id';
LBL_OLD_ROOM
: 'OLD_ROOM'|'old_room';
// $>
//======================================================
i made normal_text only to retrieve its value not the full production , whereas it returns to me in the console the full parameters passed in , i don't know why ???
any ideas .
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070907/6d08efed/attachment.html
More information about the antlr-interest
mailing list