org.antlr.tool
Class GrammarSpelunker

java.lang.Object
  extended by org.antlr.tool.GrammarSpelunker

public class GrammarSpelunker
extends Object

Load a grammar file and scan it just until we learn a few items of interest. Currently: name, type, imports, tokenVocab, language option. GrammarScanner (at bottom of this class) converts grammar to stuff like: grammar Java ; options { backtrack true memoize true } import JavaDecl JavaAnnotations JavaExpr ; ... : ... First ':' or '@' indicates we can stop looking for imports/options. Then we just grab interesting grammar properties.


Nested Class Summary
static class GrammarSpelunker.Scanner
          Strip comments and then return stream of words and tokens {';', ':', '{', '}'}
 
Field Summary
protected  String grammarFileName
           
protected  String grammarModifier
           
protected  String grammarName
           
protected  List<String> importedGrammars
           
protected  String inputDirectory
           
protected  String language
           
protected  GrammarSpelunker.Scanner scanner
           
protected  String token
           
protected  String tokenVocab
           
 
Constructor Summary
GrammarSpelunker(String inputDirectory, String grammarFileName)
           
 
Method Summary
 String getGrammarModifier()
           
 String getGrammarName()
           
 List<String> getImportedGrammars()
           
 String getLanguage()
           
 String getTokenVocab()
           
protected  void grammarHeader()
           
protected  void imports()
           
static void main(String[] args)
          Tester; Give grammar filename as arg
protected  void match(String expecting)
           
protected  void options()
           
 void parse()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

grammarFileName

protected String grammarFileName

token

protected String token

scanner

protected GrammarSpelunker.Scanner scanner

grammarModifier

protected String grammarModifier

grammarName

protected String grammarName

tokenVocab

protected String tokenVocab

language

protected String language

inputDirectory

protected String inputDirectory

importedGrammars

protected List<String> importedGrammars
Constructor Detail

GrammarSpelunker

public GrammarSpelunker(String inputDirectory,
                        String grammarFileName)
Method Detail

match

protected void match(String expecting)
              throws IOException
Throws:
IOException

parse

public void parse()
           throws IOException
Throws:
IOException

grammarHeader

protected void grammarHeader()
                      throws IOException
Throws:
IOException

options

protected void options()
                throws IOException
Throws:
IOException

imports

protected void imports()
                throws IOException
Throws:
IOException

getGrammarModifier

public String getGrammarModifier()

getGrammarName

public String getGrammarName()

getTokenVocab

public String getTokenVocab()

getLanguage

public String getLanguage()

getImportedGrammars

public List<String> getImportedGrammars()

main

public static void main(String[] args)
                 throws IOException
Tester; Give grammar filename as arg

Throws:
IOException


Copyright © 2011. All Rights Reserved.