Newer
Older
using System.Collections;
using System.Collections.Generic;
[Serializable]
public class Declaration
{
public string name;
public string isProof;
public string value;
}
[Serializable]
public class Scroll
{
public string problemTheory;
public string solutionTheory;
public string label;
public string description;
public Declaration[] declarations;
//public string output;
public static Scroll generateFromJson(string json) {
return JsonUtility.FromJson<Scroll>(json);
}
public string toJson() {
return JsonUtility.ToJson(this);
}
}
*/
public class Scroll : LightScroll
{
public string label;
public string description;
public List<ScrollFact> requiredFacts;
public static List<Scroll> FromJSON(string json)
{
List<Scroll> scrolls = JsonConvert.DeserializeObject<List<Scroll>>(json);
return scrolls;
}
public static string ToJSON(FilledScroll scroll)
{
string json = Newtonsoft.Json.JsonConvert.SerializeObject(scroll);
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
return json;
}
// id of fact, positions in Description
public static List<KeyValuePair<int,int>>[] FactOccurences;
public static void InitDynamicScroll(int n)
{
FactOccurences = new List<KeyValuePair<int, int>>[n];
}
//also collects occurences to be changed later
public static string ParseString(int stringId, string raw, List<ScrollFact> scrollFacts)
{
int i = 0;
while(true)
{
char[] rawChars = raw.ToCharArray();
i = Array.FindIndex(rawChars,i, c => c == '$');
if (i == -1) break;
// Debug.Log(i);
//id of Fact, specified after the $
int toChange = (int) Char.GetNumericValue(raw[i + 1]);
//label of this Fact
string label = scrollFacts[toChange].label;
raw = raw.Remove(i,2);
raw = raw.Insert(i,label);
if(FactOccurences[toChange] == null)
{
FactOccurences[toChange] = new List<KeyValuePair<int, int>>();
}
//if (toChange >= 0) Debug.Log(stringId);
FactOccurences[toChange].Add(new KeyValuePair<int, int>(stringId,i));
}
return raw;
}
/*
public class ScrollList
{
public List<Scroll> scrolls;
}*/
public class ScrollAssignment
{
public KeyValuePair<string, JSONManager.MMTTerm> assignment;
}
public class FilledScroll
{
LightScroll scroll;
List<ScrollAssignment> assignments;
public FilledScroll(LightScroll scroll, List<ScrollAssignment> assignments)
{
this.scroll = scroll;
this.assignments = assignments;
}
}
[JsonConverter(typeof(JsonSubtypes), "kind")]
[JsonSubtypes.KnownSubType(typeof(ScrollSymbolFact), "general")]
[JsonSubtypes.KnownSubType(typeof(ScrollValueFact), "veq")]
public class UriReference
{
public string uri;
}
/**
* Class used for deserializing incoming symbol-declarations from mmt
*/
public class ScrollSymbolFact : ScrollFact
{
public MMTTerm tp;
public MMTTerm df;
}
/**
* Class used for deserializing incoming value-declarations from mmt
*/
public class ScrollValueFact : ScrollFact
MMTTerm lhs;
MMTTerm valueTp;
MMTTerm value;
MMTTerm proof;
{
public ScrollTheoryReference @ref;
}
public class ScrollTheoryReference
{
public string problemTheory;
public string solutionTheory;
}