[antlr-interest] unexpected token where it IS defined

offline314159 offline at shaw.ca
Tue Feb 10 15:47:50 PST 2004


Below is the .g file that i'm working on - bear in mind that i am
completely new to antlr and parser generators in general.

I'm using the latest antlreclipse plugin to generate the parser, and i
get the following error every time i try to compile the file as you
see it here:

rule classDef trapped:
unexpected token: WS

on line 33

Can someone tell me what i'm missing here?  Do i have to predefine the
WS token or something?  How do i make this work?

===begin vcard.g===

header {
	package aimedia.vcard.util.parser;
}

{
	import java.io.*;
}

/** This parser recognizes VCard v2.1 files
 * @author Chris Rose
 */
class VCardParser extends Parser;

options {
	k=3;	// Lookahead of only 1 character
}

tokens {
	BEGIN = "BEGIN";
	COLON = ":";
	END = "END";
	VCID = "VCARD";
	ADR = "ADR";
	ORG = "ORG";
	N = "N";
	AGENT = "AGENT";
}

vcard_file :
	(wsls)* vcard (wsls)*;	// This is the main VCard root

vcard :
	BEGIN WS* COLON WS* VCID WS* CRLF+ items CRLF+ END WS* COLON WS* VCID;
	
items : 
	(item CRLF*)*;
	
item :
	(groups ".")? actualItem;
	
actualItem :
	name (params)? COLON value CRLF |
	ADR (params)? COLON addressparts CRLF |
	ORG (params)? COLON orgparts CRLF |
	N (params)? COLON nameparts CRLF |
	AGENT (params)? COLON vcard CRLF;
	
name :
	"LOGO" | "PHOTO" | "LABEL" | "FN" | "TITLE" | 
	"SOUND" | "VERSION" | "TEL" | "EMAIL" | "TZ" | 
	"GEO" | "NOTE" | "URL" | "BDAY" | "ROLE" | 
	"REV" | "UID" | "KEY" | "MAILER" | 
	xWord;
	
value :
	// Various
	WORD*
	
params :
	(";" WS* param)*;
	
param :
	"TYPE" WS* EQUALS WS* ptypeval |
	"VALUE" WS* EQUALS WS* pvalueval |
	"ENCODING" WS* EQUALS WS* pencodingval |
	"CHARSET" WS* EQUALS WS* charsetval |
	"LANGUAGE" WS* EQUALS WS* languageval |
	xWord WS* EQUALS WS* word |
	knowntype;
	
ptypeval :
	knowntype | word;

pvalueval :
	"INLINE" | "URL" | "CONTENT-ID" | "CID" |  xWord;
	
pencodingval :
	"7BIT" | "8BIT" | "QUOTED-PRINTABLE" | "BASE64" | xWord;
	
charsetval :
	"UTF-8"; // And other charsets as defined in RFC 1521 - look it up, i
guess.

languageval:
	"EN"; // And others from rfc 1766
	
knowntype :
	"DOM" | "INTL" | "POSTAL" | "PARCEL" | "HOME" |
	"WORK" | "PREF" | "VOICE" | "FAX" | "MSG" | 
	"CELL" | "PAGER" | "BBS" | "MODEM" | "CAR" | 
	"ISDN" | "VIDEO" | "AOL" | "APPLELINK" | 
	"ATTMAIL" | "CIS" | "EWORLD" | "INTERNET" | 
	"IBMMAIL" | "MCIMAIL" | "POWERSHARE" | 
	"PRODIGY" | "TLX" | "X400" | "GIF" | "CGM" | 
	"WMF" | "BMP" | "MET" | "PMB" | "DIB" | "PICT" | 
	"TIFF" | "PDF" | "PS" | "JPEG" | "QTIME" | "MPEG" | 
	"MPEG2" | "AVI" | "WAVE" | "AIFF" | "PCM" | "X509" | 
	"PGP";
	
class VCardLexer extends Lexer;

WS : 
	' ' | '\t';

CRLF : 
	"\n" | "\n\r";

===end vcard.g===




 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
     antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/
 



More information about the antlr-interest mailing list