PageRenderTime 197ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/runtime/Java/src/main/java/org/antlr/runtime/tree/RewriteRuleNodeStream.java

https://bitbucket.org/jwalton/antlr3
Java | 72 lines | 30 code | 8 blank | 34 comment | 0 complexity | c3bc32912348c170627a62c0dde96ea9 MD5 | raw file
  1. /*
  2. [The "BSD license"]
  3. Copyright (c) 2005-2009 Terence Parr
  4. All rights reserved.
  5. Redistribution and use in source and binary forms, with or without
  6. modification, are permitted provided that the following conditions
  7. are met:
  8. 1. Redistributions of source code must retain the above copyright
  9. notice, this list of conditions and the following disclaimer.
  10. 2. Redistributions in binary form must reproduce the above copyright
  11. notice, this list of conditions and the following disclaimer in the
  12. documentation and/or other materials provided with the distribution.
  13. 3. The name of the author may not be used to endorse or promote products
  14. derived from this software without specific prior written permission.
  15. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  16. IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  17. OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  18. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  19. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  20. NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  21. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  22. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  23. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  24. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. */
  26. package org.antlr.runtime.tree;
  27. import java.util.List;
  28. /** Queues up nodes matched on left side of -> in a tree parser. This is
  29. * the analog of RewriteRuleTokenStream for normal parsers.
  30. */
  31. public class RewriteRuleNodeStream extends RewriteRuleElementStream {
  32. public RewriteRuleNodeStream(TreeAdaptor adaptor, String elementDescription) {
  33. super(adaptor, elementDescription);
  34. }
  35. /** Create a stream with one element */
  36. public RewriteRuleNodeStream(TreeAdaptor adaptor,
  37. String elementDescription,
  38. Object oneElement)
  39. {
  40. super(adaptor, elementDescription, oneElement);
  41. }
  42. /** Create a stream, but feed off an existing list */
  43. public RewriteRuleNodeStream(TreeAdaptor adaptor,
  44. String elementDescription,
  45. List<Object> elements)
  46. {
  47. super(adaptor, elementDescription, elements);
  48. }
  49. public Object nextNode() {
  50. return _next();
  51. }
  52. @Override
  53. protected Object toTree(Object el) {
  54. return adaptor.dupNode(el);
  55. }
  56. @Override
  57. protected Object dup(Object el) {
  58. // we dup every node, so don't have to worry about calling dup; short-
  59. // circuited next() so it doesn't call.
  60. throw new UnsupportedOperationException("dup can't be called for a node stream.");
  61. }
  62. }