// LLAnalyze -- Nathaniel Nystrom, February 2000
// For use in Cornell University Computer Science 412/413

// Lexical specification for grammar files.

package Iota.util.grammar;

import java.lang.System;

%%

%{
	public int yyline()
	{
		return yyline;
	}
%} 
%line
%char
%state COMMENT

ALPHA=[A-Za-z]
DIGIT=[0-9]
WHITE_SPACE_CHAR=[\r\n\ \t\b\012]
COMMENT_TEXT=([^*]|"*"+[^/])*


%% 

<YYINITIAL> ":" { return (new Yytoken(Yytoken.COLON,yyline,yytext())); }
<YYINITIAL> ";" { return (new Yytoken(Yytoken.SEMI,yyline,yytext())); }
<YYINITIAL> "(" { return (new Yytoken(Yytoken.LPAREN,yyline,yytext())); }
<YYINITIAL> ")" { return (new Yytoken(Yytoken.RPAREN,yyline,yytext())); }
<YYINITIAL> "[" { return (new Yytoken(Yytoken.LBRACKET,yyline,yytext())); }
<YYINITIAL> "]" { return (new Yytoken(Yytoken.RBRACKET,yyline,yytext())); }
<YYINITIAL> "|" { return (new Yytoken(Yytoken.OR,yyline,yytext())); }
<YYINITIAL> "*" { return (new Yytoken(Yytoken.STAR,yyline,yytext())); }
<YYINITIAL> "+" { return (new Yytoken(Yytoken.PLUS,yyline,yytext())); }
<YYINITIAL> "%%" { return (new Yytoken(Yytoken.SEPSEP,yyline,yytext())); }
<YYINITIAL> "%token" { return (new Yytoken(Yytoken.SEPTOKEN,yyline,yytext())); }
<YYINITIAL> "%start" { return (new Yytoken(Yytoken.SEPSTART,yyline,yytext())); }

<YYINITIAL> {WHITE_SPACE_CHAR}+ { }

<YYINITIAL> "/*" { yybegin(COMMENT); }

<COMMENT> "*/" { 
    		yybegin(YYINITIAL);
}
<COMMENT> {COMMENT_TEXT} { }

<YYINITIAL> {ALPHA}({ALPHA}|{DIGIT}|_)* {
	return (new Yytoken(Yytoken.ID,yyline,yytext()));
}	
<YYINITIAL,COMMENT> . {
	throw new RuntimeException(yyline +
	    ": Illegal character: <" + yytext() + ">");
}

