public static Size Parse(Parser parser, int startindent) { var i = new Size(); if (parser.curr.kw != Parser.RegKeywords.None) { throw parser.GetException("unexpected line in Size"); } i.Description = parser.GetLine(); i.SmallGroup = i.Description; if (parser.curr.indent <= startindent) { return(i); } var ind = parser.curr.indent; while (parser.curr.indent == ind) { if (parser.curr.kw != Parser.RegKeywords.SmallGroup) { throw parser.GetException("unexpected line in Size"); } i.SmallGroup = parser.GetString(i.Description); } return(i); }
public static List <Size> ParseShirtSizes(Parser parser) { parser.lineno++; var list = new List <Size>(); if (parser.curr.indent == 0) { return(list); } var startindent = parser.curr.indent; while (parser.curr.indent == startindent) { var shirtsize = new Size(); if (parser.curr.kw != Parser.RegKeywords.None) { throw parser.GetException("unexpected line"); } shirtsize.Description = parser.GetLine(); shirtsize.SmallGroup = shirtsize.Description; if (parser.curr.indent > startindent) { if (parser.curr.kw != Parser.RegKeywords.SmallGroup) { throw parser.GetException("expected SmallGroup keyword"); } shirtsize.SmallGroup = parser.GetString(shirtsize.SmallGroup); } list.Add(shirtsize); } return(list); }
public static GradeOption Parse(Parser parser, int startindent) { if (parser.curr.kw != Parser.RegKeywords.None) { throw parser.GetException("expected description only"); } var option = new GradeOption(); option.Description = parser.GetLine(); if (parser.curr.indent <= startindent) { throw parser.GetException("expected greater indent"); } if (parser.curr.kw != Parser.RegKeywords.Code) { throw parser.GetException("expected Code"); } var code = parser.GetNullInt(); if (!code.HasValue) { parser.lineno--; throw parser.GetException("expected integer code"); } option.Code = code.Value; return(option); }
public static ExtraQuestion Parse(Parser parser, int startindent) { if (parser.curr.kw != Parser.RegKeywords.None) { throw parser.GetException("unexpected line"); } return(new ExtraQuestion { Question = parser.GetLine() }); }
private void ParseAgeGroups(Parser parser) { parser.lineno++; if (parser.curr.indent == 0) { return; } var startindent = parser.curr.indent; while (parser.curr.indent == startindent) { var agegroup = new AgeGroup(); if (parser.curr.kw != Parser.RegKeywords.None) { throw parser.GetException("unexpected line"); } agegroup.SmallGroup = parser.GetLine(); var m = parser.agerange.Match(agegroup.SmallGroup); if (!m.Success) { parser.lineno--; throw parser.GetException("expected age range like 0-12"); } agegroup.StartAge = m.Groups["start"].Value.ToInt(); agegroup.EndAge = m.Groups["end"].Value.ToInt(); if (parser.curr.indent <= startindent) { throw parser.GetException("expected either indented SmallGroup or Fee"); } var ind = parser.curr.indent; while (parser.curr.indent == ind) { switch (parser.curr.kw) { case Parser.RegKeywords.SmallGroup: agegroup.SmallGroup = parser.GetString(agegroup.SmallGroup); break; case Parser.RegKeywords.Fee: agegroup.Fee = parser.GetDecimal(); break; default: throw parser.GetException("unexpected line"); } } AgeGroups.Add(agegroup); } }
public static DropdownItem Parse(Parser parser, int startindent) { var i = new DropdownItem(); if (parser.curr.kw != Parser.RegKeywords.None) { throw parser.GetException("unexpected line in Dropdown"); } i.Description = parser.GetLine(); i.SmallGroup = i.Description; if (parser.curr.indent <= startindent) { return(i); } var ind = parser.curr.indent; while (parser.curr.indent == ind) { switch (parser.curr.kw) { case Parser.RegKeywords.SmallGroup: i.SmallGroup = parser.GetString(i.Description); break; case Parser.RegKeywords.Fee: i.Fee = parser.GetDecimal(); break; case Parser.RegKeywords.Limit: i.Limit = parser.GetNullInt(); break; case Parser.RegKeywords.Time: i.MeetingTime = parser.GetDateTime(); break; default: throw parser.GetException("unexpected line in DropdownItem"); } } return(i); }
public static MenuItem Parse(Parser parser, int startindent) { var menuitem = new MenuItem(); if (parser.curr.kw != Parser.RegKeywords.None) { throw parser.GetException("unexpected line in MenuItem"); } menuitem.Description = parser.GetLine(); menuitem.SmallGroup = menuitem.Description; if (parser.curr.indent <= startindent) { return(menuitem); } var ind = parser.curr.indent; while (parser.curr.indent == ind) { switch (parser.curr.kw) { case Parser.RegKeywords.SmallGroup: menuitem.SmallGroup = parser.GetString(menuitem.Description); break; case Parser.RegKeywords.Fee: menuitem.Fee = parser.GetDecimal(); break; case Parser.RegKeywords.Limit: menuitem.Limit = parser.GetNullInt(); break; case Parser.RegKeywords.Time: menuitem.MeetingTime = parser.GetDateTime(); break; default: throw parser.GetException("unexpected line in MenuItem"); } } return(menuitem); }
public static TimeSlot Parse(Parser parser, int startindent) { var timeslot = new TimeSlot(); if (parser.curr.kw != Parser.RegKeywords.None) { throw parser.GetException("unexpected line in TimeSlots"); } timeslot.Description = parser.GetLine(); if (parser.curr.indent <= startindent) { return(timeslot); } var ind = parser.curr.indent; while (parser.curr.indent == ind) { switch (parser.curr.kw) { case Parser.RegKeywords.Time: timeslot.Time = parser.GetTime(); break; case Parser.RegKeywords.DayOfWeek: timeslot.DayOfWeek = parser.GetInt(); break; case Parser.RegKeywords.Limit: timeslot.Limit = parser.GetInt(); break; default: throw parser.GetException("unexpected line in TimeSlot"); } } return(timeslot); }
public static YesNoQuestion Parse(Parser parser, int startindent) { var q = new YesNoQuestion(); if (parser.curr.kw != Parser.RegKeywords.None) { throw parser.GetException("unexpected line"); } q.Question = parser.GetLine(); if (parser.curr.indent <= startindent) { throw parser.GetException("Expected SmallGroup indented"); } if (parser.curr.kw != Parser.RegKeywords.SmallGroup) { throw parser.GetException("Expected SmallGroup keyword"); } if (!parser.curr.value.HasValue()) { throw parser.GetException("Expected SmallGroup value"); } q.SmallGroup = parser.GetString(); return(q); }
public static List<Size> ParseShirtSizes(Parser parser) { parser.lineno++; var list = new List<Size>(); if (parser.curr.indent == 0) return list; var startindent = parser.curr.indent; while (parser.curr.indent == startindent) { var shirtsize = new Size(); if (parser.curr.kw != Parser.RegKeywords.None) throw parser.GetException("unexpected line"); shirtsize.Description = parser.GetLine(); shirtsize.SmallGroup = shirtsize.Description; if (parser.curr.indent > startindent) { if (parser.curr.kw != Parser.RegKeywords.SmallGroup) throw parser.GetException("expected SmallGroup keyword"); shirtsize.SmallGroup = parser.GetString(shirtsize.SmallGroup); } list.Add(shirtsize); } return list; }
public static YesNoQuestion Parse(Parser parser, int startindent) { var q = new YesNoQuestion(); if (parser.curr.kw != Parser.RegKeywords.None) throw parser.GetException("unexpected line"); q.Question = parser.GetLine(); if (parser.curr.indent <= startindent) throw parser.GetException("Expected SmallGroup indented"); if (parser.curr.kw != Parser.RegKeywords.SmallGroup) throw parser.GetException("Expected SmallGroup keyword"); if (!parser.curr.value.HasValue()) throw parser.GetException("Expected SmallGroup value"); q.SmallGroup = parser.GetString(); return q; }
public static TimeSlot Parse(Parser parser, int startindent) { var timeslot = new TimeSlot(); if (parser.curr.kw != Parser.RegKeywords.None) throw parser.GetException("unexpected line in TimeSlots"); timeslot.Description = parser.GetLine(); if (parser.curr.indent <= startindent) return timeslot; var ind = parser.curr.indent; while (parser.curr.indent == ind) { switch (parser.curr.kw) { case Parser.RegKeywords.Time: timeslot.Time = parser.GetTime(); break; case Parser.RegKeywords.DayOfWeek: timeslot.DayOfWeek = parser.GetInt(); break; case Parser.RegKeywords.Limit: timeslot.Limit = parser.GetInt(); break; default: throw parser.GetException("unexpected line in TimeSlot"); } } return timeslot; }
public static GradeOption Parse(Parser parser, int startindent) { if (parser.curr.kw != Parser.RegKeywords.None) throw parser.GetException("expected description only"); var option = new GradeOption(); option.Description = parser.GetLine(); if (parser.curr.indent <= startindent) throw parser.GetException("expected greater indent"); if (parser.curr.kw != Parser.RegKeywords.Code) throw parser.GetException("expected Code"); var code = parser.GetNullInt(); if (!code.HasValue) { parser.lineno--; throw parser.GetException("expected integer code"); } option.Code = code.Value; return option; }
private void ParseAgeGroups(Parser parser) { parser.lineno++; if (parser.curr.indent == 0) return; var startindent = parser.curr.indent; while (parser.curr.indent == startindent) { var agegroup = new AgeGroup(); if (parser.curr.kw != Parser.RegKeywords.None) throw parser.GetException("unexpected line"); agegroup.SmallGroup = parser.GetLine(); var m = parser.agerange.Match(agegroup.SmallGroup); if (!m.Success) { parser.lineno--; throw parser.GetException("expected age range like 0-12"); } agegroup.StartAge = m.Groups["start"].Value.ToInt(); agegroup.EndAge = m.Groups["end"].Value.ToInt(); if (parser.curr.indent <= startindent) throw parser.GetException("expected either indented SmallGroup or Fee"); var ind = parser.curr.indent; while (parser.curr.indent == ind) { switch (parser.curr.kw) { case Parser.RegKeywords.SmallGroup: agegroup.SmallGroup = parser.GetString(agegroup.SmallGroup); break; case Parser.RegKeywords.Fee: agegroup.Fee = parser.GetDecimal(); break; default: throw parser.GetException("unexpected line"); } } AgeGroups.Add(agegroup); } }
public static Size Parse(Parser parser, int startindent) { var i = new Size(); if (parser.curr.kw != Parser.RegKeywords.None) throw parser.GetException("unexpected line in Size"); i.Description = parser.GetLine(); i.SmallGroup = i.Description; if (parser.curr.indent <= startindent) return i; var ind = parser.curr.indent; while (parser.curr.indent == ind) { if (parser.curr.kw != Parser.RegKeywords.SmallGroup) throw parser.GetException("unexpected line in Size"); i.SmallGroup = parser.GetString(i.Description); } return i; }
public static MenuItem Parse(Parser parser, int startindent) { var menuitem = new MenuItem(); if (parser.curr.kw != Parser.RegKeywords.None) throw parser.GetException("unexpected line in MenuItem"); menuitem.Description = parser.GetLine(); menuitem.SmallGroup = menuitem.Description; if (parser.curr.indent <= startindent) return menuitem; var ind = parser.curr.indent; while (parser.curr.indent == ind) { switch (parser.curr.kw) { case Parser.RegKeywords.SmallGroup: menuitem.SmallGroup = parser.GetString(menuitem.Description); break; case Parser.RegKeywords.Fee: menuitem.Fee = parser.GetDecimal(); break; case Parser.RegKeywords.Limit: menuitem.Limit = parser.GetNullInt(); break; case Parser.RegKeywords.Time: menuitem.MeetingTime = parser.GetDateTime(); break; default: throw parser.GetException("unexpected line in MenuItem"); } } return menuitem; }
public static ExtraQuestion Parse(Parser parser, int startindent) { if (parser.curr.kw != Parser.RegKeywords.None) throw parser.GetException("unexpected line"); return new ExtraQuestion { Question = parser.GetLine() }; }
public static DropdownItem Parse(Parser parser, int startindent) { var i = new DropdownItem(); if (parser.curr.kw != Parser.RegKeywords.None) throw parser.GetException("unexpected line in Dropdown"); i.Description = parser.GetLine(); i.SmallGroup = i.Description; if (parser.curr.indent <= startindent) return i; var ind = parser.curr.indent; while (parser.curr.indent == ind) { switch (parser.curr.kw) { case Parser.RegKeywords.SmallGroup: i.SmallGroup = parser.GetString(i.Description); break; case Parser.RegKeywords.Fee: i.Fee = parser.GetDecimal(); break; case Parser.RegKeywords.Limit: i.Limit = parser.GetNullInt(); break; case Parser.RegKeywords.Time: i.MeetingTime = parser.GetDateTime(); break; default: throw parser.GetException("unexpected line in DropdownItem"); } } return i; }