Lines Matching refs:input

2 /// Base functions to initialize and manipulate any input stream
37 // Generic 8 bit input such as latin-1
55 static void antlr3InputClose (pANTLR3_INPUT_STREAM input);
56 static void antlr3InputReset (pANTLR3_INPUT_STREAM input);
57 static void antlr38BitReuse (pANTLR3_INPUT_STREAM input, pANTLR3_UINT8 inString, ANTLR3_UINT32 size, pANTLR3_UINT8 name);
58 static void * antlr38BitLT (pANTLR3_INPUT_STREAM input, ANTLR3_INT32 lt);
59 static ANTLR3_UINT32 antlr38BitSize (pANTLR3_INPUT_STREAM input);
60 static pANTLR3_STRING antlr38BitSubstr (pANTLR3_INPUT_STREAM input, ANTLR3_MARKER start, ANTLR3_MARKER stop);
61 static ANTLR3_UINT32 antlr38BitGetLine (pANTLR3_INPUT_STREAM input);
62 static void * antlr38BitGetLineBuf (pANTLR3_INPUT_STREAM input);
63 static ANTLR3_UINT32 antlr38BitGetCharPosition (pANTLR3_INPUT_STREAM input);
64 static void antlr38BitSetLine (pANTLR3_INPUT_STREAM input, ANTLR3_UINT32 line);
65 static void antlr38BitSetCharPosition (pANTLR3_INPUT_STREAM input, ANTLR3_UINT32 position);
66 static void antlr38BitSetNewLineChar (pANTLR3_INPUT_STREAM input, ANTLR3_UINT32 newlineChar);
67 static void antlr38BitSetUcaseLA (pANTLR3_INPUT_STREAM input, ANTLR3_BOOLEAN flag);
85 static pANTLR3_STRING antlr3UTF16Substr (pANTLR3_INPUT_STREAM input, ANTLR3_MARKER start, ANTLR3_MARKER stop);
101 static pANTLR3_STRING antlr3UTF32Substr (pANTLR3_INPUT_STREAM input, ANTLR3_MARKER start, ANTLR3_MARKER stop);
114 /// \brief Common function to setup function interface for an 8 bit input stream.
116 /// \param input Input stream context pointer
120 /// by any or at least some, other input streams. Therefore it is perfectly acceptable
122 /// that would not work for the particular input encoding, such as consume for instance.
125 antlr38BitSetupStream (pANTLR3_INPUT_STREAM input)
129 input->strFactory = antlr3StringFactoryNew(input->encoding);
136 antlr3GenericSetupStream (pANTLR3_INPUT_STREAM input)
138 /* Install function pointers for an 8 bit input
143 input->istream = antlr3IntStreamNew();
144 input->istream->type = ANTLR3_CHARSTREAM;
145 input->istream->super = input;
149 input->istream->consume = antlr38BitConsume; // Consume the next 8 bit character in the buffer
150 input->istream->_LA = antlr38BitLA; // Return the UTF32 character at offset n (1 based)
151 input->istream->index = antlr38BitIndex; // Current index (offset from first character
152 input->istream->mark = antlr38BitMark; // Record the current lex state for later restore
153 input->istream->rewind = antlr38BitRewind; // How to rewind the input
154 input->istream->rewindLast = antlr38BitRewindLast; // How to rewind the input
155 input->istream->seek = antlr38BitSeek; // How to seek to a specific point in the stream
156 input->istream->release = antlr38BitRelease; // Reset marks after mark n
157 input->istream->getSourceName = antlr38BitGetSourceName; // Return a string that names the input source
161 input->close = antlr3InputClose; // Close down the stream completely
162 input->free = antlr3InputClose; // Synonym for free
163 input->reset = antlr3InputReset; // Reset input to start
164 input->reuse = antlr38BitReuse; // Install a new input string and reset
165 input->_LT = antlr38BitLT; // Same as _LA for 8 bit file
166 input->size = antlr38BitSize; // Return the size of the input buffer
167 input->substr = antlr38BitSubstr; // Return a string from the input stream
168 input->getLine = antlr38BitGetLine; // Return the current line number in the input stream
169 input->getLineBuf = antlr38BitGetLineBuf; // Return a pointer to the start of the current line being consumed
170 input->getCharPositionInLine = antlr38BitGetCharPosition; // Return the offset into the current line of input
171 input->setLine = antlr38BitSetLine; // Set the input stream line number (does not set buffer pointers)
172 input->setCharPositionInLine = antlr38BitSetCharPosition; // Set the offset in to the current line (does not set any pointers)
173 input->SetNewLineChar = antlr38BitSetNewLineChar; // Set the value of the newline trigger character
174 input->setUcaseLA = antlr38BitSetUcaseLA; // Changes the LA function to return upper case always
176 input->charByteSize = 1; // Size in bytes of characters in this stream.
180 input->markers = NULL;
182 /* Set up the input stream brand new
184 input->reset(input);
189 input->SetNewLineChar(input, (ANTLR3_UCHAR)'\n');
198 /** \brief Close down an input stream and free any memory allocated by it.
200 * \param input Input stream context pointer
203 antlr3InputClose(pANTLR3_INPUT_STREAM input)
205 // Close any markers in the input stream
207 if (input->markers != NULL)
209 input->markers->free(input->markers);
210 input->markers = NULL;
215 if (input->strFactory != NULL)
217 input->strFactory->close(input->strFactory);
220 // Free the input stream buffer if we allocated it
222 if (input->isAllocated && input->data != NULL)
224 ANTLR3_FREE(input->data);
225 input->data = NULL;
228 input->istream->free(input->istream);
232 ANTLR3_FREE(input);
239 antlr38BitSetUcaseLA (pANTLR3_INPUT_STREAM input, ANTLR3_BOOLEAN flag)
245 input->istream->_LA = antlr38BitLA_ucase;
251 input->istream->_LA = antlr38BitLA;
256 /** \brief Reset a re-startable input stream to the start
258 * \param input Input stream context pointer
261 antlr3InputReset(pANTLR3_INPUT_STREAM input)
264 input->nextChar = input->data; /* Input at first character */
265 input->line = 1; /* starts at line 1 */
266 input->charPositionInLine = -1;
267 input->currentLine = input->data;
268 input->markDepth = 0; /* Reset markers */
272 if (input->markers != NULL)
274 input->markers->clear(input->markers);
280 input->markers = antlr3VectorNew(0);
284 /** Install a new source code in to a working input stream so that the
285 * input stream can be reused.
288 antlr38BitReuse(pANTLR3_INPUT_STREAM input, pANTLR3_UINT8 inString, ANTLR3_UINT32 size, pANTLR3_UINT8 name)
290 input->isAllocated = ANTLR3_FALSE;
291 input->data = inString;
292 input->sizeBuf = size;
297 if (input->istream->streamName == NULL)
299 input->istream->streamName = input->strFactory->newStr(input->strFactory, name == NULL ? (pANTLR3_UINT8)"-memory-" : name);
300 input->fileName = input->istream->streamName;
304 input->istream->streamName->set(input->istream->streamName, (name == NULL ? (const char *)"-memory-" : (const char *)name));
307 input->reset(input);
310 /** \brief Consume the next character in an 8 bit input stream
312 * \param input Input stream context pointer
317 pANTLR3_INPUT_STREAM input;
319 input = ((pANTLR3_INPUT_STREAM) (is->super));
321 if ((pANTLR3_UINT8)(input->nextChar) < (((pANTLR3_UINT8)input->data) + input->sizeBuf))
325 input->charPositionInLine++;
327 if ((ANTLR3_UCHAR)(*((pANTLR3_UINT8)input->nextChar)) == input->newlineChar)
329 /* Reset for start of a new line of input
331 input->line++;
332 input->charPositionInLine = 0;
333 input->currentLine = (void *)(((pANTLR3_UINT8)input->nextChar) + 1);
338 input->nextChar = (void *)(((pANTLR3_UINT8)input->nextChar) + 1);
342 /** \brief Return the input element assuming an 8 bit ascii input
344 * \param[in] input Input stream context pointer
345 * \param[in] la 1 based offset of next input stream element
347 * \return Next input character in internal ANTLR3 encoding (UTF32)
352 pANTLR3_INPUT_STREAM input;
354 input = ((pANTLR3_INPUT_STREAM) (is->super));
356 if (( ((pANTLR3_UINT8)input->nextChar) + la - 1) >= (((pANTLR3_UINT8)input->data) + input->sizeBuf))
362 return (ANTLR3_UCHAR)(*((pANTLR3_UINT8)input->nextChar + la - 1));
366 /** \brief Return the input element assuming an 8 bit input and
371 * \param[in] input Input stream context pointer
372 * \param[in] la 1 based offset of next input stream element
374 * \return Next input character in internal ANTLR3 encoding (UTF32)
379 pANTLR3_INPUT_STREAM input;
381 input = ((pANTLR3_INPUT_STREAM) (is->super));
383 if (( ((pANTLR3_UINT8)input->nextChar) + la - 1) >= (((pANTLR3_UINT8)input->data) + input->sizeBuf))
389 return (ANTLR3_UCHAR)toupper((*((pANTLR3_UINT8)input->nextChar + la - 1)));
394 /** \brief Return the input element assuming an 8 bit ascii input
396 * \param[in] input Input stream context pointer
397 * \param[in] lt 1 based offset of next input stream element
399 * \return Next input character in internal ANTLR3 encoding (UTF32)
402 antlr38BitLT(pANTLR3_INPUT_STREAM input, ANTLR3_INT32 lt)
409 return (ANTLR3_FUNC_PTR(input->istream->_LA(input->istream, lt)));
413 * \param[in] input Input stream context pointer
418 pANTLR3_INPUT_STREAM input;
420 input = ((pANTLR3_INPUT_STREAM) (is->super));
422 return (ANTLR3_MARKER)(((pANTLR3_UINT8)input->nextChar));
425 /** \brief Return the size of the current input stream, as an 8Bit file
426 * which in this case is the total input. Other implementations may provide
430 * \param[in] input Input stream context pointer
433 antlr38BitSize(pANTLR3_INPUT_STREAM input)
435 return input->sizeBuf;
438 /** \brief Mark the current input point in an 8Bit 8 bit stream
439 * such as a file stream, where all the input is available in the
448 pANTLR3_INPUT_STREAM input;
450 input = ((pANTLR3_INPUT_STREAM) (is->super));
454 input->markDepth++;
459 if (input->markDepth > input->markers->count)
465 input->markers->add(input->markers, state, ANTLR3_FREE_FUNC); /* No special structure, just free() on delete */
469 state = (pANTLR3_LEX_STATE)input->markers->get(input->markers, input->markDepth - 1);
479 state->charPositionInLine = input->charPositionInLine;
480 state->currentLine = input->currentLine;
481 state->line = input->line;
482 state->nextChar = input->nextChar;
484 is->lastMarker = input->markDepth;
488 return input->markDepth;
490 /** \brief Rewind the lexer input to the state specified by the last produced mark.
492 * \param[in] input Input stream context pointer
495 * Assumes 8 Bit input stream.
503 /** \brief Rewind the lexer input to the state specified by the supplied mark.
505 * \param[in] input Input stream context pointer
508 * Assumes 8 Bit input stream.
514 pANTLR3_INPUT_STREAM input;
516 input = ((pANTLR3_INPUT_STREAM) is->super);
520 input->istream->release(input->istream, mark);
524 state = (pANTLR3_LEX_STATE)input->markers->get(input->markers, (ANTLR3_UINT32)(mark - 1));
526 /* Seek input pointer to the requested point (note we supply the void *pointer
533 input->charPositionInLine = state->charPositionInLine;
534 input->currentLine = state->currentLine;
535 input->line = state->line;
536 input->nextChar = state->nextChar;
542 /** \brief Rewind the lexer input to the state specified by the supplied mark.
544 * \param[in] input Input stream context pointer
547 * Assumes 8 Bit input stream.
552 pANTLR3_INPUT_STREAM input;
554 input = ((pANTLR3_INPUT_STREAM) (is->super));
559 input->markDepth = (ANTLR3_UINT32)(mark - 1);
562 /** \brief Rewind the lexer input to the state specified by the supplied mark.
564 * \param[in] input Input stream context pointer
567 * Assumes 8 Bit input stream.
573 pANTLR3_INPUT_STREAM input;
575 input = ANTLR3_FUNC_PTR(((pANTLR3_INPUT_STREAM) is->super));
578 * input point, then we assume that we are resetting from a mark
581 if (seekPoint <= (ANTLR3_MARKER)(input->nextChar))
583 input->nextChar = ((pANTLR3_UINT8) seekPoint);
587 count = (ANTLR3_UINT32)(seekPoint - (ANTLR3_MARKER)(input->nextChar));
595 /** Return a substring of the 8 bit input stream in
598 * \param input Input stream context pointer
599 * \param start Offset in input stream where the string starts
600 * \param stop Offset in the input stream where the string ends.
603 antlr38BitSubstr (pANTLR3_INPUT_STREAM input, ANTLR3_MARKER start, ANTLR3_MARKER stop)
605 return input->strFactory->newPtr(input->strFactory, (pANTLR3_UINT8)start, (ANTLR3_UINT32)(stop - start + 1));
608 /** \brief Return the line number as understood by the 8 bit input stream.
610 * \param input Input stream context pointer
611 * \return Line number in input stream that we believe we are working on.
614 antlr38BitGetLine (pANTLR3_INPUT_STREAM input)
616 return input->line;
619 /** Return a pointer into the input stream that points at the start
620 * of the current input line as triggered by the end of line character installed
623 * \param[in] input
626 antlr38BitGetLineBuf (pANTLR3_INPUT_STREAM input)
628 return input->currentLine;
631 /** Return the current offset in to the current line in the input stream.
633 * \param input Input stream context pointer
637 antlr38BitGetCharPosition (pANTLR3_INPUT_STREAM input)
639 return input->charPositionInLine;
642 /** Set the current line number as understood by the input stream.
644 * \param input Input stream context pointer
645 * \param line Line number to tell the input stream we are on
654 antlr38BitSetLine (pANTLR3_INPUT_STREAM input, ANTLR3_UINT32 line)
656 input->line = line;
661 * \param[in] input Input stream context pointer
665 * This does not set the actual pointers in the input stream, it is purely for reporting
669 antlr38BitSetCharPosition (pANTLR3_INPUT_STREAM input, ANTLR3_UINT32 position)
671 input->charPositionInLine = position;
674 /** Set the newline trigger character in the input stream to the supplied parameter.
676 * \param[in] input Input stream context pointer
681 * are the same encodings), but the input stream catered to by this function is 8 bit
685 antlr38BitSetNewLineChar (pANTLR3_INPUT_STREAM input, ANTLR3_UINT32 newlineChar)
687 input->newlineChar = newlineChar;
691 /// \brief Common function to setup function interface for a UTF16 or UCS2 input stream.
693 /// \param input Input stream context pointer
696 /// - Strictly speaking, there is no such thing as a UCS2 input stream as the term
699 /// input stream is able to handle it without any special code.
702 antlr3UTF16SetupStream (pANTLR3_INPUT_STREAM input, ANTLR3_BOOLEAN machineBigEndian, ANTLR3_BOOLEAN inputBigEndian)
708 input->strFactory = antlr3StringFactoryNew(input->encoding);
712 input->istream->index = antlr3UTF16Index; // Calculate current index in input stream, UTF16 based
713 input->substr = antlr3UTF16Substr; // Return a string from the input stream
714 input->istream->seek = antlr3UTF16Seek; // How to seek to a specific point in the stream
716 // We must install different UTF16 routines according to whether the input
725 // Machine is Big Endian, if the input is also then install the
726 // methods that do not access input by bytes and reverse them.
733 input->istream->consume = antlr3UTF16Consume; // Consume the next UTF16 character in the buffer
734 input->istream->_LA = antlr3UTF16LA; // Return the UTF32 character at offset n (1 based)
738 // Need to use methods that know that the input is little endian
740 input->istream->consume = antlr3UTF16ConsumeLE; // Consume the next UTF16 character in the buffer
741 input->istream->_LA = antlr3UTF16LALE; // Return the UTF32 character at offset n (1 based)
747 // Machine is Little Endian, if the input is also then install the
748 // methods that do not access input by bytes and reverse them.
755 input->istream->consume = antlr3UTF16Consume; // Consume the next UTF16 character in the buffer
756 input->istream->_LA = antlr3UTF16LA; // Return the UTF32 character at offset n (1 based)
760 // Need to use methods that know that the input is Big Endian
762 input->istream->consume = antlr3UTF16ConsumeBE; // Consume the next UTF16 character in the buffer
763 input->istream->_LA = antlr3UTF16LABE; // Return the UTF32 character at offset n (1 based)
769 input->charByteSize = 2; // Size in bytes of characters in this stream.
773 /// \brief Consume the next character in a UTF16 input stream
775 /// \param input Input stream context pointer
780 pANTLR3_INPUT_STREAM input;
784 input = ((pANTLR3_INPUT_STREAM) (is->super));
788 if ((pANTLR3_UINT8)(input->nextChar) < (((pANTLR3_UINT8)input->data) + input->sizeBuf))
792 input->charPositionInLine++;
794 if ((ANTLR3_UCHAR)(*((pANTLR3_UINT16)input->nextChar)) == input->newlineChar)
796 // Reset for start of a new line of input
798 input->line++;
799 input->charPositionInLine = 0;
800 input->currentLine = (void *)(((pANTLR3_UINT16)input->nextChar) + 1);
807 ch = *((UTF16*)input->nextChar);
811 input->nextChar = (void *)(((pANTLR3_UINT16)input->nextChar) + 1);
820 if ((pANTLR3_UINT8)(input->nextChar) < (((pANTLR3_UINT8)input->data) + input->sizeBuf))
824 ch2 = *((UTF16*)input->nextChar);
832 input->nextChar = (void *)(((pANTLR3_UINT16)input->nextChar) + 1);
849 /// \brief Return the input element assuming an 8 bit ascii input
851 /// \param[in] input Input stream context pointer
852 /// \param[in] la 1 based offset of next input stream element
854 /// \return Next input character in internal ANTLR3 encoding (UTF32)
859 pANTLR3_INPUT_STREAM input;
864 // Find the input interface and where we are currently pointing to
865 // in the input stream
867 input = ((pANTLR3_INPUT_STREAM) (is->super));
868 nextChar = input->nextChar;
874 while (--la > 0 && (pANTLR3_UINT8)nextChar < ((pANTLR3_UINT8)input->data) + input->sizeBuf )
876 // Advance our copy of the input pointer
889 if ((pANTLR3_UINT8)(nextChar) < (((pANTLR3_UINT8)input->data) + input->sizeBuf))
919 // We need to go backwards from our input point
921 while (la++ < 0 && (pANTLR3_UINT8)nextChar > (pANTLR3_UINT8)input->data )
947 if ( (pANTLR3_UINT8)nextChar >= (((pANTLR3_UINT8)input->data) + input->sizeBuf))
964 if ((pANTLR3_UINT8)(nextChar) < (((pANTLR3_UINT8)input->data) + input->sizeBuf))
993 /// \param[in] input Input stream context pointer
998 pANTLR3_INPUT_STREAM input;
1000 input = ((pANTLR3_INPUT_STREAM) (is->super));
1002 return (ANTLR3_MARKER)(input->nextChar);
1005 /// \brief Rewind the lexer input to the state specified by the supplied mark.
1007 /// \param[in] input Input stream context pointer
1010 /// Assumes UTF16 input stream.
1015 pANTLR3_INPUT_STREAM input;
1017 input = ((pANTLR3_INPUT_STREAM) is->super);
1020 // input point, then we assume that we are resetting from a mark
1024 if (seekPoint <= (ANTLR3_MARKER)(input->nextChar))
1026 input->nextChar = (void *)seekPoint;
1032 while (is->_LA(is, 1) != ANTLR3_CHARSTREAM_EOF && seekPoint < (ANTLR3_MARKER)input->nextChar)
1038 /// \brief Return a substring of the UTF16 input stream in
1041 /// \param input Input stream context pointer
1042 /// \param start Offset in input stream where the string starts
1043 /// \param stop Offset in the input stream where the string ends.
1046 antlr3UTF16Substr (pANTLR3_INPUT_STREAM input, ANTLR3_MARKER start, ANTLR3_MARKER stop)
1048 return input->strFactory->newPtr(input->strFactory, (pANTLR3_UINT8)start, ((ANTLR3_UINT32_CAST(stop - start))/2) + 1);
1051 /// \brief Consume the next character in a UTF16 input stream when the input is Little Endian and the machine is not
1052 /// Note that the UTF16 routines do not do any substantial verification of the input stream as for performance
1053 /// sake, we assume it is validly encoded. So if a low surrogate is found at the curent input position then we
1054 /// just consume it. Surrogate pairs should be seen as Hi, Lo. So if we have a Lo first, then the input stream
1057 /// \param input Input stream context pointer
1062 pANTLR3_INPUT_STREAM input;
1066 input = ((pANTLR3_INPUT_STREAM) (is->super));
1070 if ((pANTLR3_UINT8)(input->nextChar) < (((pANTLR3_UINT8)input->data) + input->sizeBuf))
1074 input->charPositionInLine++;
1076 if ((ANTLR3_UCHAR)(*((pANTLR3_UINT16)input->nextChar)) == input->newlineChar)
1078 // Reset for start of a new line of input
1080 input->line++;
1081 input->charPositionInLine = 0;
1082 input->currentLine = (void *)(((pANTLR3_UINT16)input->nextChar) + 1);
1089 ch = *((pANTLR3_UINT8)input->nextChar) + (*((pANTLR3_UINT8)input->nextChar + 1) <<8);
1093 input->nextChar = (void *)(((pANTLR3_UINT16)input->nextChar) + 1);
1102 if ((pANTLR3_UINT8)(input->nextChar) < (((pANTLR3_UINT8)input->data) + input->sizeBuf))
1104 ch2 = *((pANTLR3_UINT8)input->nextChar) + (*((pANTLR3_UINT8)input->nextChar + 1) <<8);
1112 input->nextChar = (void *)(((pANTLR3_UINT16)input->nextChar) + 1);
1129 /// \brief Return the input element assuming a UTF16 input when the input is Little Endian and the machine is not
1131 /// \param[in] input Input stream context pointer
1132 /// \param[in] la 1 based offset of next input stream element
1134 /// \return Next input character in internal ANTLR3 encoding (UTF32)
1139 pANTLR3_INPUT_STREAM input;
1144 // Find the input interface and where we are currently pointing to
1145 // in the input stream
1147 input = ((pANTLR3_INPUT_STREAM) (is->super));
1148 nextChar = input->nextChar;
1154 while (--la > 0 && (pANTLR3_UINT8)nextChar < ((pANTLR3_UINT8)input->data) + input->sizeBuf )
1156 // Advance our copy of the input pointer
1170 if ((pANTLR3_UINT8)(nextChar) < (((pANTLR3_UINT8)input->data) + input->sizeBuf))
1200 // We need to go backwards from our input point
1202 while (la++ < 0 && (pANTLR3_UINT8)nextChar > (pANTLR3_UINT8)input->data )
1229 if ( (pANTLR3_UINT8)nextChar >= (((pANTLR3_UINT8)input->data) + input->sizeBuf))
1247 if ((pANTLR3_UINT8)(nextChar) < (((pANTLR3_UINT8)input->data) + input->sizeBuf))
1274 /// \brief Consume the next character in a UTF16 input stream when the input is Big Endian and the machine is not
1276 /// \param input Input stream context pointer
1281 pANTLR3_INPUT_STREAM input;
1285 input = ((pANTLR3_INPUT_STREAM) (is->super));
1289 if ((pANTLR3_UINT8)(input->nextChar) < (((pANTLR3_UINT8)input->data) + input->sizeBuf))
1293 input->charPositionInLine++;
1295 if ((ANTLR3_UCHAR)(*((pANTLR3_UINT16)input->nextChar)) == input->newlineChar)
1297 // Reset for start of a new line of input
1299 input->line++;
1300 input->charPositionInLine = 0;
1301 input->currentLine = (void *)(((pANTLR3_UINT16)input->nextChar) + 1);
1308 ch = *((pANTLR3_UINT8)input->nextChar + 1) + (*((pANTLR3_UINT8)input->nextChar ) <<8);
1312 input->nextChar = (void *)(((pANTLR3_UINT16)input->nextChar) + 1);
1321 if ((pANTLR3_UINT8)(input->nextChar) < (((pANTLR3_UINT8)input->data) + input->sizeBuf))
1325 ch2 = *((pANTLR3_UINT8)input->nextChar + 1) + (*((pANTLR3_UINT8)input->nextChar ) <<8);
1333 input->nextChar = (void *)(((pANTLR3_UINT16)input->nextChar) + 1);
1350 /// \brief Return the input element assuming a UTF16 input when the input is Little Endian and the machine is not
1352 /// \param[in] input Input stream context pointer
1353 /// \param[in] la 1 based offset of next input stream element
1355 /// \return Next input character in internal ANTLR3 encoding (UTF32)
1360 pANTLR3_INPUT_STREAM input;
1365 // Find the input interface and where we are currently pointing to
1366 // in the input stream
1368 input = ((pANTLR3_INPUT_STREAM) (is->super));
1369 nextChar = input->nextChar;
1375 while (--la > 0 && (pANTLR3_UINT8)nextChar < ((pANTLR3_UINT8)input->data) + input->sizeBuf )
1377 // Advance our copy of the input pointer
1391 if ((pANTLR3_UINT8)(nextChar) < (((pANTLR3_UINT8)input->data) + input->sizeBuf))
1421 // We need to go backwards from our input point
1423 while (la++ < 0 && (pANTLR3_UINT8)nextChar > (pANTLR3_UINT8)input->data )
1450 if ( (pANTLR3_UINT8)nextChar >= (((pANTLR3_UINT8)input->data) + input->sizeBuf))
1468 if ((pANTLR3_UINT8)(nextChar) < (((pANTLR3_UINT8)input->data) + input->sizeBuf))
1495 /// \brief Common function to setup function interface for a UTF3 input stream.
1497 /// \param input Input stream context pointer
1500 antlr3UTF32SetupStream (pANTLR3_INPUT_STREAM input, ANTLR3_BOOLEAN machineBigEndian, ANTLR3_BOOLEAN inputBigEndian)
1506 input->strFactory = antlr3StringFactoryNew(input->encoding);
1510 input->istream->index = antlr3UTF32Index; // Calculate current index in input stream, UTF16 based
1511 input->substr = antlr3UTF32Substr; // Return a string from the input stream
1512 input->istream->seek = antlr3UTF32Seek; // How to seek to a specific point in the stream
1513 input->istream->consume = antlr3UTF32Consume; // Consume the next UTF32 character in the buffer
1515 // We must install different UTF32 LA routines according to whether the input
1523 // Machine is Big Endian, if the input is also then install the
1524 // methods that do not access input by bytes and reverse them.
1531 input->istream->_LA = antlr3UTF32LA; // Return the UTF32 character at offset n (1 based)
1535 // Need to use methods that know that the input is little endian
1537 input->istream->_LA = antlr3UTF32LALE; // Return the UTF32 character at offset n (1 based)
1543 // Machine is Little Endian, if the input is also then install the
1544 // methods that do not access input by bytes and reverse them.
1551 input->istream->_LA = antlr3UTF32LA; // Return the UTF32 character at offset n (1 based)
1555 // Need to use methods that know that the input is Big Endian
1557 input->istream->_LA = antlr3UTF32LABE; // Return the UTF32 character at offset n (1 based)
1562 input->charByteSize = 4; // Size in bytes of characters in this stream.
1565 /** \brief Consume the next character in a UTF32 input stream
1567 * \param input Input stream context pointer
1572 pANTLR3_INPUT_STREAM input;
1574 input = ((pANTLR3_INPUT_STREAM) (is->super));
1578 if ((pANTLR3_UINT8)(input->nextChar) < (((pANTLR3_UINT8)input->data) + input->sizeBuf))
1582 input->charPositionInLine++;
1584 if ((ANTLR3_UCHAR)(*((pANTLR3_UINT32)input->nextChar)) == input->newlineChar)
1586 /* Reset for start of a new line of input
1588 input->line++;
1589 input->charPositionInLine = 0;
1590 input->currentLine = (void *)(((pANTLR3_UINT32)input->nextChar) + 1);
1595 input->nextChar = (void *)(((pANTLR3_UINT32)input->nextChar) + 1);
1600 /// \param[in] input Input stream context pointer
1605 pANTLR3_INPUT_STREAM input;
1607 input = ((pANTLR3_INPUT_STREAM) (is->super));
1609 return (ANTLR3_MARKER)(input->nextChar);
1612 /// \brief Return a substring of the UTF16 input stream in
1615 /// \param input Input stream context pointer
1616 /// \param start Offset in input stream where the string starts
1617 /// \param stop Offset in the input stream where the string ends.
1620 antlr3UTF32Substr (pANTLR3_INPUT_STREAM input, ANTLR3_MARKER start, ANTLR3_MARKER stop)
1622 return input->strFactory->newPtr(input->strFactory, (pANTLR3_UINT8)start, ((ANTLR3_UINT32_CAST(stop - start))/4) + 1);
1625 /// \brief Rewind the lexer input to the state specified by the supplied mark.
1627 /// \param[in] input Input stream context pointer
1630 /// Assumes UTF32 input stream.
1635 pANTLR3_INPUT_STREAM input;
1637 input = ((pANTLR3_INPUT_STREAM) is->super);
1640 // input point, then we assume that we are resetting from a mark
1644 if (seekPoint <= (ANTLR3_MARKER)(input->nextChar))
1646 input->nextChar = (void *)seekPoint;
1652 while (is->_LA(is, 1) != ANTLR3_CHARSTREAM_EOF && seekPoint < (ANTLR3_MARKER)input->nextChar)
1659 /** \brief Return the input element assuming a UTF32 input in natural machine byte order
1661 * \param[in] input Input stream context pointer
1662 * \param[in] la 1 based offset of next input stream element
1664 * \return Next input character in internal ANTLR3 encoding (UTF32)
1669 pANTLR3_INPUT_STREAM input;
1671 input = ((pANTLR3_INPUT_STREAM) (is->super));
1673 if (( ((pANTLR3_UINT8)input->nextChar) + la - 1) >= (((pANTLR3_UINT8)input->data) + input->sizeBuf))
1679 return (ANTLR3_UCHAR)(*((pANTLR3_UINT32)input->nextChar + la - 1));
1683 /** \brief Return the input element assuming a UTF32 input in little endian byte order
1685 * \param[in] input Input stream context pointer
1686 * \param[in] la 1 based offset of next input stream element
1688 * \return Next input character in internal ANTLR3 encoding (UTF32)
1693 pANTLR3_INPUT_STREAM input;
1695 input = ((pANTLR3_INPUT_STREAM) (is->super));
1697 if (( ((pANTLR3_UINT8)input->nextChar) + la - 1) >= (((pANTLR3_UINT8)input->data) + input->sizeBuf))
1705 c = (ANTLR3_UCHAR)(*((pANTLR3_UINT32)input->nextChar + la - 1));
1713 /** \brief Return the input element assuming a UTF32 input in big endian byte order
1715 * \param[in] input Input stream context pointer
1716 * \param[in] la 1 based offset of next input stream element
1718 * \return Next input character in internal ANTLR3 encoding (UTF32)
1724 pANTLR3_INPUT_STREAM input;
1726 input = ((pANTLR3_INPUT_STREAM) (is->super));
1728 if (( ((pANTLR3_UINT8)input->nextChar) + la - 1) >= (((pANTLR3_UINT8)input->data) + input->sizeBuf))
1736 c = (ANTLR3_UCHAR)(*((pANTLR3_UINT32)input->nextChar + la - 1));
1745 /// \brief Common function to setup function interface for a UTF8 input stream.
1747 /// \param input Input stream context pointer
1750 antlr3UTF8SetupStream (pANTLR3_INPUT_STREAM input)
1756 input->strFactory = antlr3StringFactoryNew(input->encoding);
1760 input->istream->consume = antlr3UTF8Consume; // Consume the next UTF32 character in the buffer
1761 input->istream->_LA = antlr3UTF8LA; // Return the UTF32 character at offset n (1 based)
1762 input->charByteSize = 0; // Size in bytes of characters in this stream.
1799 /** \brief Consume the next character in a UTF8 input stream
1801 * \param input Input stream context pointer
1806 pANTLR3_INPUT_STREAM input;
1811 input = ((pANTLR3_INPUT_STREAM) (is->super));
1813 nextChar = input->nextChar;
1815 if (nextChar < (((pANTLR3_UINT8)input->data) + input->sizeBuf))
1819 input->charPositionInLine++;
1825 if (nextChar + extraBytesToRead >= (((pANTLR3_UINT8)input->data) + input->sizeBuf))
1827 input->nextChar = (((pANTLR3_UINT8)input->data) + input->sizeBuf);
1845 // Magically correct the input value
1848 if (ch == input->newlineChar)
1850 /* Reset for start of a new line of input
1852 input->line++;
1853 input->charPositionInLine = 0;
1854 input->currentLine = (void *)nextChar;
1857 // Update input pointer
1859 input->nextChar = nextChar;
1862 /** \brief Return the input element assuming a UTF8 input
1864 * \param[in] input Input stream context pointer
1865 * \param[in] la 1 based offset of next input stream element
1867 * \return Next input character in internal ANTLR3 encoding (UTF32)
1872 pANTLR3_INPUT_STREAM input;
1877 input = ((pANTLR3_INPUT_STREAM) (is->super));
1879 nextChar = input->nextChar;
1892 if (nextChar < (((pANTLR3_UINT8)input->data) + input->sizeBuf))
1906 if (nextChar >= (((pANTLR3_UINT8)input->data) + input->sizeBuf))
1921 while (nextChar > (pANTLR3_UINT8)input->data && la++ < 0)
1943 if (nextChar + extraBytesToRead >= (((pANTLR3_UINT8)input->data) + input->sizeBuf))
1960 // Magically correct the input value
2008 /// \brief Common function to setup function interface for a EBCDIC input stream.
2010 /// \param input Input stream context pointer
2013 antlr3EBCDICSetupStream (pANTLR3_INPUT_STREAM input)
2017 input->strFactory = antlr3StringFactoryNew(input->encoding);
2021 input->istream->_LA = antlr3EBCDICLA; // Return the UTF32 character at offset n (1 based)
2022 input->charByteSize = 1; // Size in bytes of characters in this stream.
2025 /// \brief Return the input element assuming an 8 bit EBCDIC input
2027 /// \param[in] input Input stream context pointer
2028 /// \param[in] la 1 based offset of next input stream element
2030 /// \return Next input character in internal ANTLR3 encoding (UTF32) after translation
2036 pANTLR3_INPUT_STREAM input;
2038 input = ((pANTLR3_INPUT_STREAM) (is->super));
2040 if (( ((pANTLR3_UINT8)input->nextChar) + la - 1) >= (((pANTLR3_UINT8)input->data) + input->sizeBuf))
2048 return e2a[(*((pANTLR3_UINT8)input->nextChar + la - 1))];