[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Grammar -- identifier token



> -----Original Message-----
> From: markmann@daimi.au.dk [mailto:markmann@daimi.au.dk]
> Sent: terça-feira, 20 de Agosto de 2002 14:42
> To: sablecc-list@sable.mcgill.ca
> Subject: Grammar -- identifier token
> 
> I want to make a token, that recognise your genuine 
> identifier, and the array identifier. 
> 
> That is it should accept: Exp and Exp[] and Id[][][]

This seems to work:

Helpers
	letter = [ ['a' .. 'z'] + ['A'..'Z'] ];
	digit = ['0' .. '9'];
	name = letter ( letter | digit | '_' )*;

Tokens
	id = name;
	array = name '[]'+;

Productions

goal =
	{id} id |
	{array} array;


Carlos

----
Carlos Costa e Silva <carlos@keysoft.pt>