Code cleanup.
This commit is contained in:
@@ -348,38 +348,6 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#region Definitions
|
||||
public class InputDefinition {
|
||||
public int dim;
|
||||
public string pdim;
|
||||
public bool notnull;
|
||||
public PairList<Identifier, PdtExpression> pass;
|
||||
}
|
||||
public class JudgeDefinition {
|
||||
public PdtExpression clip;
|
||||
public PdtExpression input;
|
||||
public PdtExpression hit;
|
||||
public PdtExpression persist;
|
||||
public Identifier[] pass;
|
||||
public Identifier[] miss;
|
||||
public PairList<ScoreOperation, PdtExpression> scores;
|
||||
public int stack;
|
||||
public int prop = 1;
|
||||
}
|
||||
public class ScoreOperation {
|
||||
public Identifier name;
|
||||
public Identifier op;
|
||||
public override string ToString() {
|
||||
if (op == default(Identifier)) return name.ToString();
|
||||
else return string.Format("{0} {1}", name, op);
|
||||
}
|
||||
}
|
||||
public class ScoreDefinition {
|
||||
public PdtExpression value;
|
||||
public float init = 0;
|
||||
public string format = "";
|
||||
}
|
||||
#endregion
|
||||
|
||||
[Serializable]
|
||||
public class JudgePropagationException : Exception {
|
||||
|
@@ -65,12 +65,42 @@ namespace Cryville.Crtr {
|
||||
constraints.PrePatch(chart);
|
||||
}
|
||||
}
|
||||
public class InputDefinition {
|
||||
public int dim;
|
||||
public string pdim;
|
||||
public bool notnull;
|
||||
public PairList<Identifier, PdtExpression> pass;
|
||||
}
|
||||
public class JudgeDefinitionCollection {
|
||||
[ElementList]
|
||||
public Dictionary<Identifier, JudgeDefinition> Judges = new Dictionary<Identifier, JudgeDefinition>();
|
||||
[PropertyList]
|
||||
public Dictionary<Identifier, PdtExpression> Areas = new Dictionary<Identifier, PdtExpression>();
|
||||
}
|
||||
public class JudgeDefinition {
|
||||
public int stack;
|
||||
public int prop;
|
||||
public PdtExpression clip;
|
||||
public PdtExpression input;
|
||||
public PdtExpression hit;
|
||||
public PdtExpression persist; // TODO Compat
|
||||
public Identifier[] pass; // TODO Compat
|
||||
public Identifier[] miss; // TODO Compat
|
||||
public PairList<ScoreOperation, PdtExpression> scores; // TODO Compat
|
||||
}
|
||||
public class ScoreOperation {
|
||||
public Identifier name;
|
||||
public Identifier op;
|
||||
public override string ToString() {
|
||||
if (op == default(Identifier)) return name.ToString();
|
||||
else return string.Format("{0} {1}", name, op);
|
||||
}
|
||||
}
|
||||
public class ScoreDefinition {
|
||||
public PdtExpression value;
|
||||
public float init = 0;
|
||||
public string format = "";
|
||||
}
|
||||
public class Constraint {
|
||||
static readonly PropOp.Arbitrary _arbop = new PropOp.Arbitrary();
|
||||
[ElementList]
|
||||
|
@@ -10,47 +10,50 @@ namespace Cryville.Crtr {
|
||||
readonly List<RulesetSelector> s = new List<RulesetSelector>();
|
||||
readonly List<string> a = new List<string>();
|
||||
protected override object InterpretKey(Type type) {
|
||||
if (type == typeof(Constraint)) {
|
||||
s.Clear(); a.Clear();
|
||||
string key = "";
|
||||
while (true) {
|
||||
int pp = Position;
|
||||
switch (cc) {
|
||||
case '@':
|
||||
GetChar();
|
||||
a.Add(GetIdentifier());
|
||||
break;
|
||||
case '$':
|
||||
GetChar();
|
||||
s.Add(new RulesetSelector.CreateItem());
|
||||
key = null;
|
||||
break;
|
||||
case '#':
|
||||
GetChar();
|
||||
s.Add(new RulesetSelector.Index());
|
||||
break;
|
||||
case '>':
|
||||
GetChar();
|
||||
s.Add(new RulesetSelector.Property(GetExp()));
|
||||
break;
|
||||
case ';':
|
||||
case ':':
|
||||
return new PropertyKey(a.Contains("var") ? PropertyType.Variable : PropertyType.Property, key);
|
||||
case '{':
|
||||
return new RulesetSelectors(s);
|
||||
case '}':
|
||||
return null;
|
||||
default:
|
||||
var p4 = GetIdentifier();
|
||||
s.Add(new RulesetSelector.EventType(p4));
|
||||
if (key != null) key += p4;
|
||||
break;
|
||||
}
|
||||
ws();
|
||||
if (Position == pp) throw new FormatException("Invalid selector or key format");
|
||||
if (type == typeof(Constraint))
|
||||
return InterpretConstraintKey();
|
||||
else
|
||||
return base.InterpretKey(type);
|
||||
}
|
||||
object InterpretConstraintKey() {
|
||||
s.Clear(); a.Clear();
|
||||
string key = "";
|
||||
while (true) {
|
||||
int pp = Position;
|
||||
switch (cc) {
|
||||
case '@':
|
||||
GetChar();
|
||||
a.Add(GetIdentifier());
|
||||
break;
|
||||
case '$':
|
||||
GetChar();
|
||||
s.Add(new RulesetSelector.CreateItem());
|
||||
key = null;
|
||||
break;
|
||||
case '#':
|
||||
GetChar();
|
||||
s.Add(new RulesetSelector.Index());
|
||||
break;
|
||||
case '>':
|
||||
GetChar();
|
||||
s.Add(new RulesetSelector.Property(GetExp()));
|
||||
break;
|
||||
case ';':
|
||||
case ':':
|
||||
return new PropertyKey(a.Contains("var") ? PropertyType.Variable : PropertyType.Property, key);
|
||||
case '{':
|
||||
return new RulesetSelectors(s);
|
||||
case '}':
|
||||
return null;
|
||||
default:
|
||||
var p4 = GetIdentifier();
|
||||
s.Add(new RulesetSelector.EventType(p4));
|
||||
if (key != null) key += p4;
|
||||
break;
|
||||
}
|
||||
ws();
|
||||
if (Position == pp) throw new FormatException("Invalid selector or key format");
|
||||
}
|
||||
else return base.InterpretKey(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user