-/** \file\r
- * Defines the the class interface for an antlr3 INTSTREAM.\r
- * \r
- * Certain functionality (such as DFAs for instance) abstract the stream of tokens\r
- * or characters in to a steam of integers. Hence this structure should be included\r
- * in any stream that is able to provide the output as a stream of integers (which is anything\r
- * basically.\r
- *\r
- * There are no specific implementations of the methods in this interface in general. Though\r
- * for purposes of casting and so on, it may be necesssary to implement a function with\r
- * the signature in this interface which abstracts the base immplementation. In essence though\r
- * the base stream provides a pointer to this interface, within which it installs its\r
- * normal match() functions and so on. Interaces such as DFA are then passed the pANTLR3_INT_STREAM\r
- * and can treat any input as an int stream. \r
- *\r
- * For instance, a lexer implements a pANTLR3_BASE_RECOGNIZER, within which there is a pANTLR3_INT_STREAM.\r
- * However, a pANTLR3_INPUT_STREAM also provides a pANTLR3_INT_STREAM, which it has constructed from\r
- * it's normal interface when it was created. This is then pointed at by the pANTLR_BASE_RECOGNIZER\r
- * when it is intialized with a pANTLR3_INPUT_STREAM.\r
- *\r
- * Similarly if a pANTLR3_BASE_RECOGNIZER is initialized with a pANTLR3_TOKEN_STREAM, then the \r
- * pANTLR3_INT_STREAM is taken from the pANTLR3_TOKEN_STREAM. \r
- *\r
- * If a pANTLR3_BASE_RECOGNIZER is initialized with a pANTLR3_TREENODE_STREAM, then guess where\r
- * the pANTLR3_INT_STREAM comes from?\r
- *\r
- * Note that because the context pointer points to the actual interface structure that is providing\r
- * the ANTLR3_INT_STREAM it is defined as a (void *) in this interface. There is no direct implementation\r
- * of an ANTLR3_INT_STREAM (unless someone did not understand what I was doing here =;?P\r
- */\r
-#ifndef _ANTLR3_INTSTREAM_H\r
-#define _ANTLR3_INTSTREAM_H\r
-\r
-// [The "BSD licence"]\r
-// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC\r
-// http://www.temporal-wave.com\r
-// http://www.linkedin.com/in/jimidle\r
-//\r
-// All rights reserved.\r
-//\r
-// Redistribution and use in source and binary forms, with or without\r
-// modification, are permitted provided that the following conditions\r
-// are met:\r
-// 1. Redistributions of source code must retain the above copyright\r
-// notice, this list of conditions and the following disclaimer.\r
-// 2. Redistributions in binary form must reproduce the above copyright\r
-// notice, this list of conditions and the following disclaimer in the\r
-// documentation and/or other materials provided with the distribution.\r
-// 3. The name of the author may not be used to endorse or promote products\r
-// derived from this software without specific prior written permission.\r
-//\r
-// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR\r
-// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\r
-// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\r
-// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\r
-// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\r
-// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-\r
-#include <antlr3defs.h>\r
-#include <antlr3commontoken.h>\r
-\r
-/** Type indicator for a character stream\r
- * \remark if a custom stream is created but it can be treated as\r
- * a char stream, then you may OR in this value to your type indicator\r
- */\r
-#define ANTLR3_CHARSTREAM 0x0001\r
-\r
-/** Type indicator for a Token stream\r
- * \remark if a custom stream is created but it can be treated as\r
- * a token stream, then you may OR in this value to your type indicator\r
- */\r
-#define ANTLR3_TOKENSTREAM 0x0002\r
-\r
-/** Type indicator for a common tree node stream\r
- * \remark if a custom stream is created but it can be treated as\r
- * a common tree node stream, then you may OR in this value to your type indicator\r
- */\r
-#define ANTLR3_COMMONTREENODE 0x0004\r
-\r
-/** Type mask for input stream so we can switch in the above types\r
- * \remark DO NOT USE 0x0000 as a stream type!\r
- */\r
-#define ANTLR3_INPUT_MASK 0x0007\r
-\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-typedef struct ANTLR3_INT_STREAM_struct\r
-{\r
- /** Input stream type indicator. Sometimes useful for error reporting etc.\r
- */\r
- ANTLR3_UINT32 type;\r
-\r
- /** Potentially useful in error reporting and so on, this string is\r
- * an identification of the input source. It may be NULL, so anything\r
- * attempting to access it needs to check this and substitute a sensible\r
- * default.\r
- */\r
- pANTLR3_STRING streamName;\r
-\r
- /** Pointer to the super structure that contains this interface. This\r
- * will usually be a token stream or a tree stream.\r
- */\r
- void * super;\r
-\r
- /** Last marker position allocated\r
- */\r
- ANTLR3_MARKER lastMarker;\r
-\r
- // Return a string that identifies the input source\r
- //\r
- pANTLR3_STRING (*getSourceName) (struct ANTLR3_INT_STREAM_struct * intStream);\r
-\r
- /** Consume the next 'ANTR3_UINT32' in the stream\r
- */\r
- void (*consume) (struct ANTLR3_INT_STREAM_struct * intStream);\r
-\r
- /** Get ANTLR3_UINT32 at current input pointer + i ahead where i=1 is next ANTLR3_UINT32 \r
- */\r
- ANTLR3_UINT32 (*_LA) (struct ANTLR3_INT_STREAM_struct * intStream, ANTLR3_INT32 i);\r
-\r
- /** Tell the stream to start buffering if it hasn't already. Return\r
- * current input position, index(), or some other marker so that\r
- * when passed to rewind() you get back to the same spot.\r
- * rewind(mark()) should not affect the input cursor.\r
- */\r
- ANTLR3_MARKER (*mark) (struct ANTLR3_INT_STREAM_struct * intStream);\r
- \r
- /** Return the current input symbol index 0..n where n indicates the\r
- * last symbol has been read.\r
- */\r
- ANTLR3_MARKER (*index) (struct ANTLR3_INT_STREAM_struct * intStream);\r
-\r
- /** Reset the stream so that next call to index would return marker.\r
- * The marker will usually be index() but it doesn't have to be. It's\r
- * just a marker to indicate what state the stream was in. This is\r
- * essentially calling release() and seek(). If there are markers\r
- * created after this marker argument, this routine must unroll them\r
- * like a stack. Assume the state the stream was in when this marker\r
- * was created.\r
- */\r
- void (*rewind) (struct ANTLR3_INT_STREAM_struct * intStream, ANTLR3_MARKER marker);\r
-\r
- /** Reset the stream to the last marker position, witouh destryoing the\r
- * last marker position.\r
- */\r
- void (*rewindLast) (struct ANTLR3_INT_STREAM_struct * intStream);\r
-\r
- /** You may want to commit to a backtrack but don't want to force the\r
- * stream to keep bookkeeping objects around for a marker that is\r
- * no longer necessary. This will have the same behavior as\r
- * rewind() except it releases resources without the backward seek.\r
- */\r
- void (*release) (struct ANTLR3_INT_STREAM_struct * intStream, ANTLR3_MARKER mark);\r
-\r
- /** Set the input cursor to the position indicated by index. This is\r
- * normally used to seek ahead in the input stream. No buffering is\r
- * required to do this unless you know your stream will use seek to\r
- * move backwards such as when backtracking.\r
- *\r
- * This is different from rewind in its multi-directional\r
- * requirement and in that its argument is strictly an input cursor (index).\r
- *\r
- * For char streams, seeking forward must update the stream state such\r
- * as line number. For seeking backwards, you will be presumably\r
- * backtracking using the mark/rewind mechanism that restores state and\r
- * so this method does not need to update state when seeking backwards.\r
- *\r
- * Currently, this method is only used for efficient backtracking, but\r
- * in the future it may be used for incremental parsing.\r
- */\r
- void (*seek) (struct ANTLR3_INT_STREAM_struct * intStream, ANTLR3_MARKER index);\r
-\r
- /** Only makes sense for streams that buffer everything up probably, but\r
- * might be useful to display the entire stream or for testing.\r
- */\r
- ANTLR3_UINT32 (*size) (struct ANTLR3_INT_STREAM_struct * intStream);\r
-\r
- /** Because the indirect call, though small in individual cases can\r
- * mount up if there are thousands of tokens (very large input streams), callers\r
- * of size can optionally use this cached size field.\r
- */\r
- ANTLR3_UINT32 cachedSize;\r
-\r
- /** Frees any resources that were allocated for the implementation of this\r
- * interface. Usually this is just releasing the memory allocated\r
- * for the structure itself, but it may of course do anything it need to\r
- * so long as it does not stamp on anything else.\r
- */\r
- void (*free) (struct ANTLR3_INT_STREAM_struct * stream);\r
-\r
-}\r
- ANTLR3_INT_STREAM;\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-\r
-#endif\r
-\r
+/** \file
+ * Defines the the class interface for an antlr3 INTSTREAM.
+ *
+ * Certain functionality (such as DFAs for instance) abstract the stream of tokens
+ * or characters in to a steam of integers. Hence this structure should be included
+ * in any stream that is able to provide the output as a stream of integers (which is anything
+ * basically.
+ *
+ * There are no specific implementations of the methods in this interface in general. Though
+ * for purposes of casting and so on, it may be necesssary to implement a function with
+ * the signature in this interface which abstracts the base immplementation. In essence though
+ * the base stream provides a pointer to this interface, within which it installs its
+ * normal match() functions and so on. Interaces such as DFA are then passed the pANTLR3_INT_STREAM
+ * and can treat any input as an int stream.
+ *
+ * For instance, a lexer implements a pANTLR3_BASE_RECOGNIZER, within which there is a pANTLR3_INT_STREAM.
+ * However, a pANTLR3_INPUT_STREAM also provides a pANTLR3_INT_STREAM, which it has constructed from
+ * it's normal interface when it was created. This is then pointed at by the pANTLR_BASE_RECOGNIZER
+ * when it is intialized with a pANTLR3_INPUT_STREAM.
+ *
+ * Similarly if a pANTLR3_BASE_RECOGNIZER is initialized with a pANTLR3_TOKEN_STREAM, then the
+ * pANTLR3_INT_STREAM is taken from the pANTLR3_TOKEN_STREAM.
+ *
+ * If a pANTLR3_BASE_RECOGNIZER is initialized with a pANTLR3_TREENODE_STREAM, then guess where
+ * the pANTLR3_INT_STREAM comes from?
+ *
+ * Note that because the context pointer points to the actual interface structure that is providing
+ * the ANTLR3_INT_STREAM it is defined as a (void *) in this interface. There is no direct implementation
+ * of an ANTLR3_INT_STREAM (unless someone did not understand what I was doing here =;?P
+ */
+#ifndef _ANTLR3_INTSTREAM_H
+#define _ANTLR3_INTSTREAM_H
+
+// [The "BSD licence"]
+// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC
+// http://www.temporal-wave.com
+// http://www.linkedin.com/in/jimidle
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// 1. Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// 3. The name of the author may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include <antlr3defs.h>
+#include <antlr3commontoken.h>
+
+/** Type indicator for a character stream
+ * \remark if a custom stream is created but it can be treated as
+ * a char stream, then you may OR in this value to your type indicator
+ */
+#define ANTLR3_CHARSTREAM 0x0001
+
+/** Type indicator for a Token stream
+ * \remark if a custom stream is created but it can be treated as
+ * a token stream, then you may OR in this value to your type indicator
+ */
+#define ANTLR3_TOKENSTREAM 0x0002
+
+/** Type indicator for a common tree node stream
+ * \remark if a custom stream is created but it can be treated as
+ * a common tree node stream, then you may OR in this value to your type indicator
+ */
+#define ANTLR3_COMMONTREENODE 0x0004
+
+/** Type mask for input stream so we can switch in the above types
+ * \remark DO NOT USE 0x0000 as a stream type!
+ */
+#define ANTLR3_INPUT_MASK 0x0007
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct ANTLR3_INT_STREAM_struct
+{
+ /** Input stream type indicator. Sometimes useful for error reporting etc.
+ */
+ ANTLR3_UINT32 type;
+
+ /** Potentially useful in error reporting and so on, this string is
+ * an identification of the input source. It may be NULL, so anything
+ * attempting to access it needs to check this and substitute a sensible
+ * default.
+ */
+ pANTLR3_STRING streamName;
+
+ /** Pointer to the super structure that contains this interface. This
+ * will usually be a token stream or a tree stream.
+ */
+ void * super;
+
+ /** Last marker position allocated
+ */
+ ANTLR3_MARKER lastMarker;
+
+ // Return a string that identifies the input source
+ //
+ pANTLR3_STRING (*getSourceName) (struct ANTLR3_INT_STREAM_struct * intStream);
+
+ /** Consume the next 'ANTR3_UINT32' in the stream
+ */
+ void (*consume) (struct ANTLR3_INT_STREAM_struct * intStream);
+
+ /** Get ANTLR3_UINT32 at current input pointer + i ahead where i=1 is next ANTLR3_UINT32
+ */
+ ANTLR3_UINT32 (*_LA) (struct ANTLR3_INT_STREAM_struct * intStream, ANTLR3_INT32 i);
+
+ /** Tell the stream to start buffering if it hasn't already. Return
+ * current input position, index(), or some other marker so that
+ * when passed to rewind() you get back to the same spot.
+ * rewind(mark()) should not affect the input cursor.
+ */
+ ANTLR3_MARKER (*mark) (struct ANTLR3_INT_STREAM_struct * intStream);
+
+ /** Return the current input symbol index 0..n where n indicates the
+ * last symbol has been read.
+ */
+ ANTLR3_MARKER (*index) (struct ANTLR3_INT_STREAM_struct * intStream);
+
+ /** Reset the stream so that next call to index would return marker.
+ * The marker will usually be index() but it doesn't have to be. It's
+ * just a marker to indicate what state the stream was in. This is
+ * essentially calling release() and seek(). If there are markers
+ * created after this marker argument, this routine must unroll them
+ * like a stack. Assume the state the stream was in when this marker
+ * was created.
+ */
+ void (*rewind) (struct ANTLR3_INT_STREAM_struct * intStream, ANTLR3_MARKER marker);
+
+ /** Reset the stream to the last marker position, witouh destryoing the
+ * last marker position.
+ */
+ void (*rewindLast) (struct ANTLR3_INT_STREAM_struct * intStream);
+
+ /** You may want to commit to a backtrack but don't want to force the
+ * stream to keep bookkeeping objects around for a marker that is
+ * no longer necessary. This will have the same behavior as
+ * rewind() except it releases resources without the backward seek.
+ */
+ void (*release) (struct ANTLR3_INT_STREAM_struct * intStream, ANTLR3_MARKER mark);
+
+ /** Set the input cursor to the position indicated by index. This is
+ * normally used to seek ahead in the input stream. No buffering is
+ * required to do this unless you know your stream will use seek to
+ * move backwards such as when backtracking.
+ *
+ * This is different from rewind in its multi-directional
+ * requirement and in that its argument is strictly an input cursor (index).
+ *
+ * For char streams, seeking forward must update the stream state such
+ * as line number. For seeking backwards, you will be presumably
+ * backtracking using the mark/rewind mechanism that restores state and
+ * so this method does not need to update state when seeking backwards.
+ *
+ * Currently, this method is only used for efficient backtracking, but
+ * in the future it may be used for incremental parsing.
+ */
+ void (*seek) (struct ANTLR3_INT_STREAM_struct * intStream, ANTLR3_MARKER index);
+
+ /** Only makes sense for streams that buffer everything up probably, but
+ * might be useful to display the entire stream or for testing.
+ */
+ ANTLR3_UINT32 (*size) (struct ANTLR3_INT_STREAM_struct * intStream);
+
+ /** Because the indirect call, though small in individual cases can
+ * mount up if there are thousands of tokens (very large input streams), callers
+ * of size can optionally use this cached size field.
+ */
+ ANTLR3_UINT32 cachedSize;
+
+ /** Frees any resources that were allocated for the implementation of this
+ * interface. Usually this is just releasing the memory allocated
+ * for the structure itself, but it may of course do anything it need to
+ * so long as it does not stamp on anything else.
+ */
+ void (*free) (struct ANTLR3_INT_STREAM_struct * stream);
+
+}
+ ANTLR3_INT_STREAM;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+