static void Main(string[] args) { SimpleStructure ss = new SimpleStructure(10, 20); ss.Sum(); Console.ReadLine(); }
void BaseReadLine(Token[] line) { // Not how I usually do things... Its sort of a functional pattern; I thought about using states (as classes) // but didn't feel like it... // It's quite concise and is easily understandable immediately after having written it. if (line.Length >= 2 && line[1].Text == "=") { var name = line[0].Text; var fields = new List <SimpleField>(); void readStruct(Token[] x) { var capture = name; var f = fields; if (x.Length == 2) { fields.Add(new SimpleField(x[0].Text, () => GetFormat(x[1].Text))); } else if (x.Length == 1 && x[0].Text == "}") { var format = new SimpleStructure(name, fields); TypeDeclarations.Add(format.GetDeclaration()); Formats.Add(name, format); LineReader = BaseReadLine; } else { throw new ApplicationException(); } } if (line.Length > 2) { if (line[2].Text != "{") { throw new NotImplementedException(); } LineReader = readStruct; } else { LineReader = (Token[] x) => { if (x.Length != 1 || x[0].Text != "{") { throw new ApplicationException(); } LineReader = readStruct; } }; } }
static void Main(string[] args) { int a, b; Console.WriteLine("Enter first number : "); a = int.Parse(Console.ReadLine()); Console.WriteLine("Enter second number : "); b = int.Parse(Console.ReadLine()); Console.WriteLine("input vaslures aere a={0}, b={1}", a, b); SimpleStructure strc = new SimpleStructure(a, b); strc.sum(); Console.ReadLine(); }
public void VisitSimpleStructure(SimpleStructure simpleStructure) { VisitStructure(simpleStructure); }