[antlr-interest] Several questions

Jim Idle jimi at intersystems.com
Mon Jan 1 15:39:10 PST 2007

Here is a case insenstive input stream, you should be able to adapt it
to any other type of stream. Basically this uses case insensitivity fgor
matching tokens but leaves the input stream in tact, which is generally
what is wanted:

import org.antlr.runtime.*;
import java.io.*;

 * @author jimi
public class ANTLRNoCaseFileStream  extends ANTLRFileStream
	public ANTLRNoCaseFileStream(String fileName) throws IOException
		super(fileName, null);

	public ANTLRNoCaseFileStream(String fileName, String encoding)
throws IOException {
		super(fileName, encoding);
	public int LA(int i) {
		if ( i==0 ) {
			return 0; // undefined
		if ( i<0 ) {
			i++; // e.g., translate LA(-1) to use offset 0 

		if ( (p+i-1) >= n ) {
            //System.out.println("char LA("+i+")=EOF; p="+p);
            return CharStream.EOF;
        //System.out.println("char LA("+i+")="+data.charAt(p+i-1)+";
        return Character.toUpperCase(data[p+i-1]);

-----Original Message-----
From: antlr-interest-bounces at antlr.org [mailto:antlr-interest- 

I am working on a source-to-source compiler using ANTLR 3 and
ANTLRWorks.  I have a few questions.

1. Case insensitivity - I need my grammar to be case insensitive.
There was a Wiki FAQ entry that linked to this thread:

More information about the antlr-interest mailing list