FormalEventParameter.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Xml.Linq;
  5. namespace csharp_sccd_compiler
  6. {
  7. public class FormalEventParameter : Visitable
  8. {
  9. public string name { get; private set; }
  10. public string type { get; private set; }
  11. public FormalEventParameter(XElement xml)
  12. {
  13. //Parse "name" attribute
  14. XAttribute name_attribute = xml.Attribute("name");
  15. if (name_attribute == null)
  16. throw new CompilerException("Missing name for formal event parameter.");
  17. this.name = name_attribute.Value.Trim();
  18. if (this.name == "")
  19. throw new CompilerException("Empty name for formal event parameter.");
  20. //Parse "type" attribute
  21. XAttribute type_attribute = xml.Attribute("type");
  22. if (type_attribute == null)
  23. throw new CompilerException("Missing type for formal event parameter.");
  24. this.type = type_attribute.Value.Trim();
  25. if (this.type == "")
  26. throw new CompilerException("Empty type for formal event parameter.");
  27. }
  28. public override void accept(Visitor visitor)
  29. {
  30. visitor.visit (this);
  31. }
  32. }
  33. }