|
sdr 0.7 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.cscott.sdr.calls.grm.Grm
public abstract class Grm
This class contains inner classes creating an AST for the 'natural language'
grammar of square dance calls and concepts. This AST is transformed into
a Java Speech grammar for the Sphinx speech recognition engine, which then
generates text strings. The AST is also transformed into an ANTLR v3
grammar parsing those text strings, which creates Apply
trees.
The raw rules from the call file need to be processed to remove
left recursion and to disambiguate using precedence levels. These
processed rules are written out as the
AllGrm
class, accessed via the
grammar(Program)
method, and used to drive the
CompletionEngine
.
Nested Class Summary | |
---|---|
static class |
Grm.Alt
Alternation: a|b. |
static class |
Grm.Concat
Concatanation: a b. |
static class |
Grm.Mult
Multiplicity marker: a*, a+, or a?. |
static class |
Grm.Nonterminal
A nonterminal reference to an external rule. |
static class |
Grm.Terminal
A grammar terminal: a string literal to match. |
Constructor Summary | |
---|---|
Grm()
|
Method Summary | ||
---|---|---|
abstract
|
accept(GrmVisitor<T> v)
|
|
protected abstract Grm |
buildIntern()
|
|
boolean |
equals(Object o)
|
|
protected abstract String |
getName()
|
|
protected abstract List<Grm> |
getOperands()
|
|
static Map<String,Grm> |
grammar(Program p)
Return a natural language grammar for the given square dance program. |
|
int |
hashCode()
|
|
Grm |
intern()
|
|
static Grm |
mkGrm(String... terminals)
Make a Grm which will recognize the given
sequence of terminal symbols. |
|
static Grm |
parse(String rule)
Parse a string representing a Grm . |
|
abstract int |
precedence()
|
|
String |
repr()
Return a Java phrase to reconstruct this Grm. |
|
protected abstract void |
repr(StringBuilder sb)
|
|
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Grm()
Method Detail |
---|
public abstract int precedence()
public abstract <T> T accept(GrmVisitor<T> v)
public final String toString()
toString
in class Object
public final String repr()
protected abstract void repr(StringBuilder sb)
protected abstract String getName()
protected abstract List<Grm> getOperands()
protected abstract Grm buildIntern()
public Grm intern()
public int hashCode()
hashCode
in class Object
public boolean equals(Object o)
equals
in class Object
public static Grm mkGrm(String... terminals)
Grm
which will recognize the given
sequence of terminal symbols.
public static Map<String,Grm> grammar(Program p)
Grm
s. The start production is a nonterminal named 'start'.
This grammar is generated by the EmitJava
class,
invoked from BuildGrammars
.
public static Grm parse(String rule)
Grm
. Parameter
references must be numerical.
IllegalArgumentException
- if the rule is malformed.js> Grm.parse("foo bar|bat? baz") foo bar|bat? baz
js> try { > Grm.parse("[abc]") > } catch (e) { print (e.javaException) } java.lang.IllegalArgumentException: bad grammar rule: [abc]
|
sdr 0.7 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |