1 using Mercury.Nucleus.Collections;
4 using System.Runtime.Serialization;
5 using System.Xml.Serialization;
15 namespace Mercury.Experimental
19 internal class Pair<T> : ISerializable
25 :
this(
default(T),
default(T))
28 public Pair(T fst, T snd)
34 public Pair(SerializationInfo info, StreamingContext context)
36 first = (T) info.GetValue(
"First", typeof(T));
37 second = (T) info.GetValue(
"Second", typeof(T));
40 public T First {
get {
return first; } }
42 public T Second {
get {
return second; } }
44 public void GetObjectData(SerializationInfo info, StreamingContext context)
46 info.AddValue(
"First", First, typeof(T));
47 info.AddValue(
"Second", Second, typeof(T));
52 internal class GrammarInfo
57 public string Name {
get; set; }
60 public string Path {
get; set; }
62 public string Root {
get; set; }
64 public string Epsilon {
get; set; }
66 [XmlArrayItem(
"Include")]
67 public string[] GrammarFiles {
get; set; }
69 [XmlArrayItem(
"Include")]
70 public string[] RwRulesFiles {
get; set; }
72 public bool UseStringActions {
get; set; }
74 public bool UseMercuryScanner {
get; set; }
76 public ListMultiDictionary<string,string> Scanners {
get; set; }
78 public ListMultiDictionary<string,string> Actions {
get; set; }
80 public Pair<string> RuleFunctions {
get; set; }
82 public static GrammarInfo FromXML(
string path)
84 XmlSerializer serializer =
new XmlSerializer(typeof(GrammarInfo));
86 GrammarInfo ginf = null;
87 using (StreamReader reader =
new StreamReader(path))
88 ginf = (GrammarInfo)serializer.Deserialize(reader);
93 public void ToXML(
string path)
95 XmlSerializer serializer =
new XmlSerializer(typeof(GrammarInfo));
97 using (StreamWriter writer =
new StreamWriter(path))
98 serializer.Serialize(writer,
this);