[antlr-interest] Line continuation character problem

Craig Barker cb at phoebussoftware.com
Thu Jun 10 03:27:54 PDT 2004


I've looked at the example and it does make sense. Also I've not tried it yet but I see where your re-write below is going and will let you know how it goes.
 
Many thanks,
 
Craig

	-----Original Message----- 
	From: Anthony Youngman [mailto:Anthony.Youngman at ECA-International.com] 
	Sent: Thu 10/06/2004 11:14 
	To: antlr-interest at yahoogroups.com 
	Cc: 
	Subject: RE: [antlr-interest] Line continuation character problem
	
	
	Actually, following up to myself, you can probably just forget about the setlen/getlen stuff and say AMP!
	 
	Cheers,
	Wol

  _____  

	From: Anthony Youngman 
	Sent: 10 June 2004 11:09
	To: 'antlr-interest at yahoogroups.com'
	Subject: RE: [antlr-interest] Line continuation character problem
	
	
	Okay. First things first - you NEED to look up that ESC example in the manual I gave you. But now let's try to rewrite your rule.
	 
	
	STRING_LITERAL
	// string literals - the only token that can be split with an '&'.
	options {paraphrase = "a string";}
	 : '"'! (AMP{token.setlen(token.getlen()-3);}|{greedy=false;}.)* '"'!
	 ;
	 
	What this is doing is first it finds your " to start the string. Then it looks for either an AMP, or anything that doesn't match your final " (that's the point of the "greedy = false" - the . won't eat any token that matches the following token-match). And when it finds an AMP, the setlen/getlen deletes it from the STRING_LITERAL that it's building.
	 
	This probably won't compile straight off - I've almost certainly got my cases wrong, and there's probably other minor faults. But I hope I've explained clearly what it's doing, and you should be able easily to clean it up.
	 
	Cheers,
	Wol
	 
  _____  

	From: Craig Barker [mailto:cb at phoebussoftware.com] 
	Sent: 10 June 2004 10:49
	To: antlr-interest at yahoogroups.com
	Subject: RE: [antlr-interest] Line continuation character problem
	
	
	Hi Anthony,
	 
	Thanks for your input to this, it's been doing my head in!
	 
	Indeed, I've got the following worked out so far:

	options {
	 exportVocab=PVocab;
	 k=3;
	filter=AMP;
	}
	 
	protected
	AMP
	//an & and line break.
	 :  '&' '\r' '\n' {System.out.println("& HIT!");newline();}
	 ; 
	 
	STRING_LITERAL
	// string literals - the only token that can be split with an '&'.
	options {paraphrase = "a string";}
	 : '"'! (~('"'))* '"'!
	 ;
	 
	This solves the first problem very well but the second point is that I still want the STRING_LITERAL token to be passed as one token, even when it's been split over 2 or more lines.
	 
	ie:
	 
	getrec(tag,"select * from acct,x__ir &
	where acct001 = x__ir001 and &
	x__ir006 = 'V'")
	 
	Effectively I need the 3 lines of strings to be treated as 1 single STRING_LITERAL token, eg:
	 
	getrec(tag,"select * from acct,x__ir where acct001 = x__ir001 and x_ir006 = 'V'")
	 
	and unfortuately shaving the last 3 characters wouldn't always work.
	 
	Again many thanks for your help,
	 
	Cheers
	 
	Craig
	
	
	****************************************************************************
	
	This transmission is intended for the named recipient only. It may contain private and confidential information. If this has come to you in error you must not act on anything disclosed in it, nor must you copy it, modify it, disseminate it in any way, or show it to anyone. Please e-mail the sender to inform us of the transmission error or telephone ECA International immediately and delete the e-mail from your information system.
	
	Telephone numbers for ECA International offices are: Sydney +61 (0)2 8272 5300, Hong Kong + 852 2121 2388, London +44 (0)20 7351 5000 and New York +1 212 582 2333.
	
	****************************************************************************
	
	
  _____  

	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 <mailto:antlr-interest-unsubscribe at yahoogroups.com?subject=Unsubscribe> 
		  
	*	Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service <http://docs.yahoo.com/info/terms/> . 




 
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/
 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/ms-tnef
Size: 10166 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20040610/fe0a4321/attachment.bin


More information about the antlr-interest mailing list