PageRenderTime 32ms CodeModel.GetById 8ms RepoModel.GetById 0ms app.codeStats 0ms

/src/Boo.Lang.Parser/antlr/antlr/LexerSharedInputState.cs

https://github.com/boo/boo-lang
C# | 88 lines | 56 code | 13 blank | 19 comment | 0 complexity | 361c4741366d3ffb8e9a65939d82dac8 MD5 | raw file
Possible License(s): GPL-2.0
  1. using System;
  2. using Stream = System.IO.Stream;
  3. using TextReader = System.IO.TextReader;
  4. namespace antlr
  5. {
  6. /*ANTLR Translator Generator
  7. * Project led by Terence Parr at http://www.jGuru.com
  8. * Software rights: http://www.antlr.org/license.html
  9. *
  10. * $Id:$
  11. */
  12. //
  13. // ANTLR C# Code Generator by Micheal Jordan
  14. // Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com
  15. // Anthony Oguntimehin
  16. //
  17. // With many thanks to Eric V. Smith from the ANTLR list.
  18. //
  19. /*This object contains the data associated with an
  20. * input stream of characters. Multiple lexers
  21. * share a single LexerSharedInputState to lex
  22. * the same input stream.
  23. */
  24. public class LexerSharedInputState
  25. {
  26. protected internal int column;
  27. protected internal int line;
  28. protected internal int tokenStartColumn;
  29. protected internal int tokenStartLine;
  30. protected internal InputBuffer input;
  31. /*What file (if known) caused the problem? */
  32. protected internal string filename;
  33. public int guessing;
  34. public LexerSharedInputState(InputBuffer inbuf)
  35. {
  36. initialize();
  37. input = inbuf;
  38. }
  39. public LexerSharedInputState(Stream inStream) : this(new ByteBuffer(inStream))
  40. {
  41. }
  42. public LexerSharedInputState(TextReader inReader) : this(new CharBuffer(inReader))
  43. {
  44. }
  45. private void initialize()
  46. {
  47. column = 1;
  48. line = 1;
  49. tokenStartColumn = 1;
  50. tokenStartLine = 1;
  51. guessing = 0;
  52. filename = null;
  53. }
  54. public virtual void reset()
  55. {
  56. initialize();
  57. input.reset();
  58. }
  59. public virtual void resetInput(InputBuffer ib)
  60. {
  61. reset();
  62. input = ib;
  63. }
  64. public virtual void resetInput(Stream s)
  65. {
  66. reset();
  67. input = new ByteBuffer(s);
  68. }
  69. public virtual void resetInput(TextReader tr)
  70. {
  71. reset();
  72. input = new CharBuffer(tr);
  73. }
  74. }
  75. }