|
CubeTwister 2.0alpha142 2012-02-11 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectch.randelshofer.rubik.parser.ScriptParser
public class ScriptParser
Parser for rubik's cube scripts. The tokens and syntax-rules used by the parser are read from a Notation object.
The parser supports the EBNF ISO/IEC 14977 productions shown below. Alternative syntax-rules specifiable by the Notation object are indicated in square brackets. The syntax-rules are given here for readability. The syntax-rules actually implemented by the parser are more complex, because those must be LALR1 (left-aligned left recursive with a lookahead of 1) to be parseable. The rules used by the implementation are given in the comments of the methods.
Sequence = { Expression } ;
Expression = Construct [Operator Expression] ;
Operator = Commutator | Conjugator | Rotator ;
Construct = { Prefix }, Statement, {Suffix} ;
Statement = CompoundStatement | Move | NOP | Macro ;
CompoundStatement= Grouping |
Inversion | Reflection |
Commutation | Conjugation | Rotation |
Permutation;
Affix = Construct ;
Root = Construct ;
Grouping = GroupingBegin, Sequence, GroupingEnd ;
GroupingBegin = Word ;
GroupingEnd = Word ;
Inversion = Inversion-prefix | Inversion-suffix |
Inversion-circumfix ;
Inversion-prefix = [InversionBegin], Invertor, [InversionEnd], Root ;
Inversion-suffix = Root, [InversionBegin], Invertor, [InversionEnd] ;
Inversion-circumfix = InversionBegin, Root, InversionEnd ;
Invertor = Word ;
InversionBegin = Word ;
InversionEnd = Word ;
Reflection = Reflection-prefix | Reflection-suffix |
Reflection-circumfix ;
Reflection-prefix = [ReflectionBegin], Reflector, [ReflectionEnd], Root ;
Reflection-suffix = Root, [ReflectionBegin], Reflector, [ReflectionEnd] ;
Reflection-circumfix = ReflectionBegin, Sequence, ReflectionEnd;
Reflector = Word ;
ReflectionBegin = Word ;
ReflectionEnd = Word ;
Commutation = Commutation-prefix | Commutation-suffix |
Commutation-precircumfix | Commutation-postcircumfix |
Commutation-preinfix | Commutation-postinfix ;
Commutation-prefix = CommutationBegin, Affix, CommutationEnd, Root ;
Commutation-suffix = Root, CommutationBegin, Affix, CommutationEnd ;
Commutation-precircumfix = CommutationBegin, Affix, CommutationDelim, Sequence, CommutationEnd ;
Commutation-postcircumfix = CommutationBegin, Sequence CommutationDelim, Affix, CommutationEnd ;
Commutation-preinfix = Affix, CommutationDelim, Root ;
Commutation-postinfix = Root, CommutationDelim, Affix ;
CommutationBegin = Word ;
CommutationEnd = Word ;
CommutationDelim = Word ;
Conjugation = Conjugation-prefix | Conjugation-suffix |
Conjugation-precircumfix | Conjugation-postcircumfix |
Conjugation-preinfix | Conjugation-postinfix ;
Conjugation-prefix = ConjugationBegin, Affix, ConjugationEnd, Root ;
Conjugation-suffix = Root, ConjugationBegin, Affix, ConjugationEnd ;
Conjugation-precircumfix = ConjugationBegin, Affix, ConjugationDelim, Root, ConjugationEnd ;
Conjugation-postcircumfix = ConjugationBegin, Root, ConjugationDelim, Affix, ConjugationEnd ;
Conjugation-preinfix = Affix, ConjugationDelim, Root ;
Conjugation-postinfix = Root, ConjugationDelim, Affix ;
ConjugationBegin = Word ;
ConjugationEnd = Word ;
ConjugationDelim = Word ;
Rotation = Rotation-prefix | Rotation-suffix |
Rotation-precircumfix | Rotation-postcircumfix |
Rotation-preinfix | Rotation-postinfix ;
Rotation-prefix = RotationBegin, Affix, RotationEnd, Root ;
Rotation-suffix = Root, RotationBegin, Affix, RotationEnd ;
Rotation-precircumfix = RotationBegin, Affix, RotationDelim, Sequence, RotationEnd ;
Rotation-postcircumfix = RotationBegin, Sequence, RotationDelim, Affix, RotationEnd ;
Rotation-preinfix = Affix, RotationDelim, Root ;
Rotation-postinfix = Root, RotationDelim, Affix ;
Rotator = Script ;
RotationBegin = Word ;
RotationEnd = Word ;
RotationDelim = Word ;
Permutation = Permutation-prefix | Permutation-suffix |
Permutation-precircumfix | Permutation-postcircumfix ;
Permutation-prefix = [PermSign], PermBegin, { SidePerm | EdgePerm | CornerPerm }, PermEnd ;
Permutation-suffix = PermBegin, { SidePerm | EdgePerm | CornerPerm }, PermEnd, [PermSign] ;
Permutation-precircumfix = PermBegin, [PermSign], { SidePerm | EdgePerm | CornerPerm }, PermEnd ;
Permutation-postcircumfix = PermBegin, { SidePerm | EdgePerm | CornerPerm }, [PermSign], PermEnd ;
SidePerm-prefix = [PermSign], Face, [Integer];
SidePerm-suffix = Face, [Integer], [PermSign] ;
SidePerm-precircumfix = Face, [Integer], [PermSign] ;
SidePerm-postcircumfix = [PermSign], Face, [Integer] ;
EdgePerm = Face, Face, [Integer];
CornerPerm = Face, Face, Face;
Face = Word;
Move = Word ;
NOP = Word ;
Macro = Word ;
Word = { letter | digit } ;
Integer = { digit } ;
| Constructor Summary | |
|---|---|
ScriptParser(Notation notation)
Creates a new ScriptParser. |
|
ScriptParser(Notation notation,
java.util.List<MacroNode> localMacros)
Creates a ScriptParser for the specified notation and with the specified local macros. |
|
| Method Summary | |
|---|---|
Notation |
getNotation()
|
SequenceNode |
parse(java.io.Reader r)
Parses a script. |
SequenceNode |
parse(java.io.Reader r,
Node parent)
Parses a script. |
SequenceNode |
parse(java.lang.String s)
Parses a Script. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ScriptParser(Notation notation)
notation - The notation describing the tokens and the syntax of the
scripts that can be parsed.
public ScriptParser(Notation notation,
java.util.List<MacroNode> localMacros)
notation - The notation describing the tokens and the syntax of the
scripts that can be parsed.localMacros - Local Macros Entry.key = macro identifier, Entry.value
= macro script.| Method Detail |
|---|
public Notation getNotation()
public SequenceNode parse(java.lang.String s)
throws java.io.IOException
Script = {Statement} ;
.
java.io.IOException
public SequenceNode parse(java.io.Reader r)
throws java.io.IOException
Script = {Statement} ;
.
java.io.IOException
public SequenceNode parse(java.io.Reader r,
Node parent)
throws java.io.IOException
Script = {Statement} ;
.
java.io.IOException
|
(c) Werner Randelshofer. All rights reserved. |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||