org.antlr.tool
Class GrammarSpelunker
java.lang.Object
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 {';', ':', '{', '}'} |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
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
GrammarSpelunker
public GrammarSpelunker(String inputDirectory,
String grammarFileName)
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.