Codebase list jlex / HEAD bug7.txt
HEAD

Tree @HEAD (Download .tar.gz)

bug7.txt @HEADraw · history · blame

The following JavaLex input file is in error;
an undefined macro is referenced in the rules section.
However, JavaLex generates errors into infinity,
which it shouldn't do.  
				-- Elliot

****************************************************************************

//
//      (c) Copyright 1996 PrinceNet, Inc.
//      All Rights Reserved.
//
// ------------------------------------------------------------------
//


import java.io.*;

%%

%type java_cup.runtime.Symbol
%char
%line

%{
int           firstCharinLine;
int           tabs = 0;
boolean       MacroHeaderDetected = false;

private int stringstart;
private StringBuffer charBuf = null;

private java_cup.runtime.Symbol tok(int kind) {
	return new java_cup.runtime.Symbol(kind, yychar, yychar+yylength());
}

private java_cup.runtime.Symbol tok(int kind, Object o) {
	return new java_cup.runtime.Symbol(kind, yychar, yychar+yylength(), o);
}

private void error(int line, String text) {
	System.out.println("Invalid text on line " + line + " " + text);
}

%}

%eofval{
	return tok(sym.EOF);
%eofval}


%%



<YYINITIAL>'{'	{ return tok(sym.LBRACE); }

<YYINITIAL>\}	{ return tok(sym.RBRACE); }

<YYINITIAL>" "	{ }

<YYINITIAL>\n { firstCharinLine = yychar+1; }

<YYINITIAL>. { 
	error(yyline+1, yytext());
}