FileDocCategorySizeDatePackage
LexerGrammar.javaAPI DocGlassfish v2 API5850Wed Aug 30 15:34:08 BST 2006persistence.antlr

LexerGrammar

public class LexerGrammar extends Grammar
Lexer-specific grammar subclass

Fields Summary
protected BitSet
charVocabulary
protected boolean
testLiterals
protected boolean
caseSensitiveLiterals
protected boolean
caseSensitive
true if the lexer generates case-sensitive literals testing
protected boolean
filterMode
true if lexer is to ignore all unrecognized tokens
protected String
filterRule
if filterMode is true, then filterRule can indicate an optional rule to use as the scarf language. If null, programmer used plain "filter=true" not "filter=rule".
Constructors Summary
LexerGrammar(String className_, Tool tool_, String superClass)


          
        super(className_, tool_, superClass);
        charVocabulary = new BitSet();

        // Lexer usually has no default error handling
        defaultErrorHandler = false;
    
Methods Summary
public voidgenerate()
Top-level call to generate the code

        generator.gen(this);
    
public java.lang.StringgetSuperClass()

        // If debugging, use debugger version of scanner
        if (debuggingOutput)
            return "debug.DebuggingCharScanner";
        return "CharScanner";
    
public booleangetTestLiterals()

        return testLiterals;
    
public voidprocessArguments(java.lang.String[] args)
Process command line arguments. -trace have all rules call traceIn/traceOut -traceLexer have lexical rules call traceIn/traceOut -debug generate debugging output for parser debugger

        for (int i = 0; i < args.length; i++) {
            if (args[i].equals("-trace")) {
                traceRules = true;
                antlrTool.setArgOK(i);
            }
            else if (args[i].equals("-traceLexer")) {
                traceRules = true;
                antlrTool.setArgOK(i);
            }
            else if (args[i].equals("-debug")) {
                debuggingOutput = true;
                antlrTool.setArgOK(i);
            }
        }
    
public voidsetCharVocabulary(persistence.antlr.collections.impl.BitSet b)
Set the character vocabulary used by the lexer

        charVocabulary = b;
    
public booleansetOption(java.lang.String key, persistence.antlr.Token value)
Set lexer options

        String s = value.getText();
        if (key.equals("buildAST")) {
            antlrTool.warning("buildAST option is not valid for lexer", getFilename(), value.getLine(), value.getColumn());
            return true;
        }
        if (key.equals("testLiterals")) {
            if (s.equals("true")) {
                testLiterals = true;
            }
            else if (s.equals("false")) {
                testLiterals = false;
            }
            else {
                antlrTool.warning("testLiterals option must be true or false", getFilename(), value.getLine(), value.getColumn());
            }
            return true;
        }
        if (key.equals("interactive")) {
            if (s.equals("true")) {
                interactive = true;
            }
            else if (s.equals("false")) {
                interactive = false;
            }
            else {
                antlrTool.error("interactive option must be true or false", getFilename(), value.getLine(), value.getColumn());
            }
            return true;
        }
        if (key.equals("caseSensitive")) {
            if (s.equals("true")) {
                caseSensitive = true;
            }
            else if (s.equals("false")) {
                caseSensitive = false;
            }
            else {
                antlrTool.warning("caseSensitive option must be true or false", getFilename(), value.getLine(), value.getColumn());
            }
            return true;
        }
        if (key.equals("caseSensitiveLiterals")) {
            if (s.equals("true")) {
                caseSensitiveLiterals = true;
            }
            else if (s.equals("false")) {
                caseSensitiveLiterals = false;
            }
            else {
                antlrTool.warning("caseSensitiveLiterals option must be true or false", getFilename(), value.getLine(), value.getColumn());
            }
            return true;
        }
        if (key.equals("filter")) {
            if (s.equals("true")) {
                filterMode = true;
            }
            else if (s.equals("false")) {
                filterMode = false;
            }
            else if (value.getType() == ANTLRTokenTypes.TOKEN_REF) {
                filterMode = true;
                filterRule = s;
            }
            else {
                antlrTool.warning("filter option must be true, false, or a lexer rule name", getFilename(), value.getLine(), value.getColumn());
            }
            return true;
        }
        if (key.equals("longestPossible")) {
            antlrTool.warning("longestPossible option has been deprecated; ignoring it...", getFilename(), value.getLine(), value.getColumn());
            return true;
        }
        if (super.setOption(key, value)) {
            return true;
        }
        antlrTool.error("Invalid option: " + key, getFilename(), value.getLine(), value.getColumn());
        return false;