Top Description Inners Fields Constructors Methods
org.antlr.tool

public Class GrammarSpelunker

extends Object
Class Inheritance
Imports
java.io.*, java.util.ArrayList, .List

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 and Inner Type Summary

Modifier and TypeClass and Description
public static class
GrammarSpelunker.Scanner

Strip comments and then return stream of words and tokens {';', ':', '{', '}'}

Field Summary

Modifier and TypeField and Description
protected String
protected String
protected String
protected List<String>
protected String
protected String
protected GrammarSpelunker.Scanner
protected String
protected String

Constructor Summary

AccessConstructor and Description
public
GrammarSpelunker(String inputDirectory, String grammarFileName)

Method Summary

Modifier and TypeMethod and Description
pack-priv void
public String
public String
public List<String>
public String
public String
protected void
protected void
public static void
main(String[] args)

Tester; Give grammar filename as arg

protected void
match(String expecting)

protected void
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

grammarFileNameback to summary
protected String grammarFileName
grammarModifierback to summary
protected String grammarModifier
grammarNameback to summary
protected String grammarName
importedGrammarsback to summary
protected List<String> importedGrammars
inputDirectoryback to summary
protected String inputDirectory
languageback to summary
protected String language
scannerback to summary
protected GrammarSpelunker.Scanner scanner
tokenback to summary
protected String token
tokenVocabback to summary
protected String tokenVocab

Constructor Detail

GrammarSpelunkerback to summary
public GrammarSpelunker(String inputDirectory, String grammarFileName)

Method Detail

consumeback to summary
pack-priv void consume() throws IOException
getGrammarModifierback to summary
public String getGrammarModifier()
getGrammarNameback to summary
public String getGrammarName()
getImportedGrammarsback to summary
public List<String> getImportedGrammars()
getLanguageback to summary
public String getLanguage()
getTokenVocabback to summary
public String getTokenVocab()
grammarHeaderback to summary
protected void grammarHeader() throws IOException
importsback to summary
protected void imports() throws IOException
mainback to summary
public static void main(String[] args) throws IOException

Tester; Give grammar filename as arg

matchback to summary
protected void match(String expecting) throws IOException
optionsback to summary
protected void options() throws IOException
parseback to summary
public void parse() throws IOException
org.antlr.tool back to summary

public Class GrammarSpelunker.Scanner

extends Object
Class Inheritance

Strip comments and then return stream of words and tokens {';', ':', '{', '}'}

Field Summary

Modifier and TypeField and Description
pack-priv int
c

public static final int
pack-priv Reader

Constructor Summary

AccessConstructor and Description
public
Scanner(Reader input)

Method Summary

Modifier and TypeMethod and Description
pack-priv void
pack-priv void
pack-priv String
ID()

NAME : LETTER+ ; // NAME is sequence of >=1 letter

pack-priv String
INT()

pack-priv boolean
pack-priv boolean
pack-priv boolean
public String
pack-priv String
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cback to summary
pack-priv int c
EOFback to summary
public static final int EOF
inputback to summary
pack-priv Reader input

Constructor Detail

Scannerback to summary
public Scanner(Reader input) throws IOException

Method Detail

COMMENTback to summary
pack-priv void COMMENT() throws IOException
consumeback to summary
pack-priv void consume() throws IOException
IDback to summary
pack-priv String ID() throws IOException

NAME : LETTER+ ; // NAME is sequence of >=1 letter

INTback to summary
pack-priv String INT() throws IOException
isDIGITback to summary
pack-priv boolean isDIGIT()
isID_LETTERback to summary
pack-priv boolean isID_LETTER()
isID_STARTback to summary
pack-priv boolean isID_START()
nextTokenback to summary
public String nextToken() throws IOException
STRINGback to summary
pack-priv String STRING() throws IOException