PageRenderTime 1459ms CodeModel.GetById 38ms RepoModel.GetById 20ms app.codeStats 0ms

/Dependencies/boo/lib/antlr-2.7.5/lib/csharp/src/antlr/CommonAST.cs

https://github.com/w4x/boolangstudio
C# | 123 lines | 78 code | 17 blank | 28 comment | 0 complexity | 8ce593d8471f0a00e5f9fd707f01fd97 MD5 | raw file
Possible License(s): GPL-2.0
  1. using System;
  2. using AST = antlr.collections.AST;
  3. namespace antlr
  4. {
  5. /*ANTLR Translator Generator
  6. * Project led by Terence Parr at http://www.jGuru.com
  7. * Software rights: http://www.antlr.org/license.html
  8. *
  9. * $Id:$
  10. */
  11. //
  12. // ANTLR C# Code Generator by Micheal Jordan
  13. // Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com
  14. // Anthony Oguntimehin
  15. //
  16. // With many thanks to Eric V. Smith from the ANTLR list.
  17. //
  18. /*Common AST node implementation */
  19. public class CommonAST : BaseAST
  20. {
  21. public static readonly CommonAST.CommonASTCreator Creator = new CommonASTCreator();
  22. internal int ttype = Token.INVALID_TYPE;
  23. internal string text;
  24. [Obsolete("Deprecated since version 2.7.2. Use ASTFactory.dup() instead.", false)]
  25. protected CommonAST(CommonAST another)
  26. {
  27. // don't include child/sibling pointers in Clone()/dup()
  28. //down = another.down;
  29. //right = another.right;
  30. ttype = another.ttype;
  31. text = (another.text==null) ? null : String.Copy(another.text);
  32. }
  33. /*Get the token text for this node */
  34. override public string getText()
  35. {
  36. return text;
  37. }
  38. /*Get the token type for this node */
  39. override public int Type
  40. {
  41. get { return ttype; }
  42. set { ttype = value; }
  43. }
  44. override public void initialize(int t, string txt)
  45. {
  46. Type = t;
  47. setText(txt);
  48. }
  49. override public void initialize(AST t)
  50. {
  51. setText(t.getText());
  52. Type = t.Type;
  53. }
  54. public CommonAST()
  55. {
  56. }
  57. public CommonAST(IToken tok)
  58. {
  59. initialize(tok);
  60. }
  61. override public void initialize(IToken tok)
  62. {
  63. setText(tok.getText());
  64. Type = tok.Type;
  65. }
  66. /*Set the token text for this node */
  67. override public void setText(string text_)
  68. {
  69. text = text_;
  70. }
  71. /*Set the token type for this node */
  72. override public void setType(int ttype_)
  73. {
  74. this.Type = ttype_;
  75. }
  76. #region Implementation of ICloneable
  77. [Obsolete("Deprecated since version 2.7.2. Use ASTFactory.dup() instead.", false)]
  78. override public object Clone()
  79. {
  80. return new CommonAST(this);
  81. }
  82. #endregion
  83. public class CommonASTCreator : ASTNodeCreator
  84. {
  85. public CommonASTCreator() {}
  86. /// <summary>
  87. /// Returns the fully qualified name of the AST type that this
  88. /// class creates.
  89. /// </summary>
  90. public override string ASTNodeTypeName
  91. {
  92. get
  93. {
  94. return typeof(antlr.CommonAST).FullName;;
  95. }
  96. }
  97. /// <summary>
  98. /// Constructs a <see cref="AST"/> instance.
  99. /// </summary>
  100. public override AST Create()
  101. {
  102. return new CommonAST();
  103. }
  104. }
  105. }
  106. }