Hi Loic, how goin' ? Maybe you should set less rules at lexer level. In your grammar you may not get what you expect from CHAR and APPLICATION_ID, the first eating aggressively the chars you expect to see in the second. I don't know how it was with ANTLR2 but with ANTLR3 uppercase tokens are lexer rules.
Cheers, c. On Wed, Dec 2, 2009 at 6:15 PM, <[email protected]> wrote: > > Hello, > I'm relatively new to antlr v3. > > I'm trying to write a parser that should be able to parse the following > (SWIFT block 1) input: > > {1:F01PARBDEFFXXXX0001000000} > > > I wish the parser to be able to then work with the following rule: > > block_1: '{1:' > APPLICATION_ID > SERVICE_ID > ADDRESS > SESSION_NUMBER > SEQUENCE_NUMBER > '}' > ; > > with tokens: > > APPLICATION_ID: 'F' | 'A' | 'L'; > > SERVICE_ID: '01' | '02'; > > fragment CHAR: 'A' .. 'Z' | '0' .. '9'; > > ADDRESS: CHAR CHAR CHAR CHAR CHAR CHAR CHAR CHAR CHAR CHAR CHAR CHAR; > > fragment DIGIT: '0' .. '1'; > > SESSION_NUMBER: DIGIT DIGIT DIGIT DIGIT; > > SEQUENCE_NUMBER: DIGIT DIGIT DIGIT DIGIT DIGIT DIGIT; > > However it doesn't work. Do you know an elegant way to work with this kind > of > tokens? I mean to define length defined tokens and to be able to work > without > "token recognition overlapp". > > (I'm open to combined grammar or not solution) > > Could the "filter" Lexer option help me there? > > > Thanks in advance. > > Regards, > Loïc > > > This message and any attachments (the "message") is > intended solely for the addressees and is confidential. > If you receive this message in error, please delete it and > immediately notify the sender. Any use not in accord with > its purpose, any dissemination or disclosure, either whole > or partial, is prohibited except formal approval. The internet > can not guarantee the integrity of this message. > BNP PARIBAS (and its subsidiaries) shall (will) not > therefore be liable for the message if modified. > Do not print this message unless it is necessary, > consider the environment. > > --------------------------------------------- > > Ce message et toutes les pieces jointes (ci-apres le > "message") sont etablis a l'intention exclusive de ses > destinataires et sont confidentiels. Si vous recevez ce > message par erreur, merci de le detruire et d'en avertir > immediatement l'expediteur. Toute utilisation de ce > message non conforme a sa destination, toute diffusion > ou toute publication, totale ou partielle, est interdite, sauf > autorisation expresse. L'internet ne permettant pas > d'assurer l'integrite de ce message, BNP PARIBAS (et ses > filiales) decline(nt) toute responsabilite au titre de ce > message, dans l'hypothese ou il aurait ete modifie. > N'imprimez ce message que si necessaire, > pensez a l'environnement. > > > List: http://www.antlr.org/mailman/listinfo/antlr-interest > Unsubscribe: > http://www.antlr.org/mailman/options/antlr-interest/your-email-address > > List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address -- You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.
