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

Grammar -- identifier token



Hi,

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[][][]

I have tried the following:

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

and

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

Tokens
  id = id;
  type_id = id array*;

in various combinations with and without parentheses.

What am I doing wrong?

I have found a solution where I fold it out and whenever I need the
type_id, I have either a id or a type_id, but I am very curious to
find out if there is a better way to do it.


Helle

-- 
Helle Markmann			http://www.daimi.au.dk/~markmann

"Jo śldre de gamle Ordsprog bliver, desto bedre passer de til Tiden."
						R. Storm P.