BinaryTerminalParser.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /// Spart License (zlib/png)
  2. ///
  3. ///
  4. /// Copyright (c) 2003 Jonathan de Halleux
  5. ///
  6. /// This software is provided 'as-is', without any express or implied warranty.
  7. /// In no event will the authors be held liable for any damages arising from
  8. /// the use of this software.
  9. ///
  10. /// Permission is granted to anyone to use this software for any purpose,
  11. /// including commercial applications, and to alter it and redistribute it
  12. /// freely, subject to the following restrictions:
  13. ///
  14. /// 1. The origin of this software must not be misrepresented; you must not
  15. /// claim that you wrote the original software. If you use this software in a
  16. /// product, an acknowledgment in the product documentation would be
  17. /// appreciated but is not required.
  18. ///
  19. /// 2. Altered source versions must be plainly marked as such, and must not be
  20. /// misrepresented as being the original software.
  21. ///
  22. /// 3. This notice may not be removed or altered from any source distribution.
  23. ///
  24. /// Author: Jonathan de Halleuxusing System;
  25. namespace Spart.Parsers
  26. {
  27. using System;
  28. public abstract class BinaryTerminalParser : TerminalParser
  29. {
  30. private Parser m_FirstParser;
  31. private Parser m_SecondParser;
  32. public BinaryTerminalParser(Parser first, Parser second)
  33. {
  34. FirstParser = first;
  35. SecondParser = second;
  36. }
  37. public Parser FirstParser
  38. {
  39. get
  40. {
  41. return m_FirstParser;
  42. }
  43. set
  44. {
  45. if (value == null)
  46. throw new ArgumentNullException("first parser is null");
  47. m_FirstParser = value;
  48. }
  49. }
  50. public Parser SecondParser
  51. {
  52. get
  53. {
  54. return m_SecondParser;
  55. }
  56. set
  57. {
  58. if (value == null)
  59. throw new ArgumentNullException("second parser is null");
  60. m_SecondParser = value;
  61. }
  62. }
  63. public override Parser Clone()
  64. {
  65. BinaryTerminalParser clone = base.Clone() as BinaryTerminalParser;
  66. clone.m_FirstParser = m_FirstParser.Clone();
  67. clone.m_SecondParser = m_SecondParser.Clone();
  68. return clone;
  69. }
  70. }
  71. }