org.sc3d.apt.sss.v3
Class GrammarParser

java.lang.Object
  extended by org.sc3d.apt.sss.v3.Parser
      extended by org.sc3d.apt.sss.v3.GrammarParser

public class GrammarParser
extends Parser

A subclass of Parser which parses SSS grammar specifications.


Field Summary
static Grammar.NonTerminal DECLARATION
          A Grammar which represents what the specification of SSS grammars calls a 'declaration'.
static Grammar.NonTerminal DECLARATION_PLUS
          A Grammar which represents what the specification of SSS grammars calls a 'declaration+'.
static Grammar.NonTerminal GRAMMAR
          A Grammar which represents what the specification of SSS grammars calls a 'grammar'.
static Grammar.NonTerminal GRAMMAR_PLUS
          A Grammar which represents what the specification of SSS grammars calls a 'grammar+'.
static GrammarParser PARSER
          A GrammarParser.
static Grammar.NonTerminal PRODUCTION
          A Grammar which represents what the specification of SSS grammars calls a 'production'.
static Grammar.NonTerminal PRODUCTION_PLUS
          A Grammar which represents what the specification of SSS grammars calls a 'production+'.
 
Fields inherited from class org.sc3d.apt.sss.v3.Parser
ndfa
 
Method Summary
static Grammar fromFile(java.lang.String filename)
          Reads the named file, parses it, and returns a Grammar, or dies trying.
static Grammar fromInputStream(java.io.InputStream in)
          Reads a string of bytes from 'in', converts it to characters, parses it, and returns a Grammar, or dies trying.
static Grammar fromString(java.lang.String grammar)
          Parses 'grammar' and returns a Grammar, or dies trying.
static void main(java.lang.String[] args)
          Takes one argument: a filename.
 java.lang.Object postProcess(Tree raw)
          Parses the contents of all brackets in the grammar file, and returns the Grammar specified by the 'ROOT' declaration.
 
Methods inherited from class org.sc3d.apt.sss.v3.Parser
interactiveTest, parse, parseTokens
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GRAMMAR

public static final Grammar.NonTerminal GRAMMAR
A Grammar which represents what the specification of SSS grammars calls a 'grammar'.

Note that this is not the Grammar of a grammar specification, which is what the specification of SSS grammars calls a 'declaration+'.


GRAMMAR_PLUS

public static final Grammar.NonTerminal GRAMMAR_PLUS
A Grammar which represents what the specification of SSS grammars calls a 'grammar+'.


PRODUCTION

public static final Grammar.NonTerminal PRODUCTION
A Grammar which represents what the specification of SSS grammars calls a 'production'.


PRODUCTION_PLUS

public static final Grammar.NonTerminal PRODUCTION_PLUS
A Grammar which represents what the specification of SSS grammars calls a 'production+'.


DECLARATION

public static final Grammar.NonTerminal DECLARATION
A Grammar which represents what the specification of SSS grammars calls a 'declaration'.


DECLARATION_PLUS

public static final Grammar.NonTerminal DECLARATION_PLUS
A Grammar which represents what the specification of SSS grammars calls a 'declaration+'.


PARSER

public static final GrammarParser PARSER
A GrammarParser. Use the value of this field instead of constructing a new GrammarParser.

Method Detail

fromString

public static Grammar fromString(java.lang.String grammar)
Parses 'grammar' and returns a Grammar, or dies trying. If 'grammar' is not a syntactically correct grammar specification, this method prints diagnostic information to 'System.err' and throws an IllegalArgumentException.


fromFile

public static Grammar fromFile(java.lang.String filename)
Reads the named file, parses it, and returns a Grammar, or dies trying. If the file could not be read, or if it was not a syntactically correct grammar specification, this method prints diagnostic information to 'System.err' and throws an IllegalArgumentException.


fromInputStream

public static Grammar fromInputStream(java.io.InputStream in)
Reads a string of bytes from 'in', converts it to characters, parses it, and returns a Grammar, or dies trying. If anything goes wrong, this method prints diagnostic information to 'System.err' and throws an IllegalArgumentException.


postProcess

public java.lang.Object postProcess(Tree raw)
Parses the contents of all brackets in the grammar file, and returns the Grammar specified by the 'ROOT' declaration.

Overrides:
postProcess in class Parser
Parameters:
raw - a Tree representing a sentence of what the specification of SSS grammars calls a 'declaration+'.
Returns:
a Grammar.

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException
Takes one argument: a filename. Parses the file as an SSS grammar specification and prints out the resulting Grammar.

Throws:
java.io.IOException