]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.databoard/cpp/DataBoardTest/libantlr3c-3.2/src/antlr3inputstream.c
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.databoard / cpp / DataBoardTest / libantlr3c-3.2 / src / antlr3inputstream.c
1 /// \file
2 /// Base functions to initialize and manipulate any input stream
3 ///
4
5 // [The "BSD licence"]
6 // Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC
7 // http://www.temporal-wave.com
8 // http://www.linkedin.com/in/jimidle
9 //
10 // All rights reserved.
11 //
12 // Redistribution and use in source and binary forms, with or without
13 // modification, are permitted provided that the following conditions
14 // are met:
15 // 1. Redistributions of source code must retain the above copyright
16 //    notice, this list of conditions and the following disclaimer.
17 // 2. Redistributions in binary form must reproduce the above copyright
18 //    notice, this list of conditions and the following disclaimer in the
19 //    documentation and/or other materials provided with the distribution.
20 // 3. The name of the author may not be used to endorse or promote products
21 //    derived from this software without specific prior written permission.
22 //
23 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24 // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 // IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27 // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
34 #include    <antlr3input.h>
35
36
37 // INT Stream API
38 //
39 static      void                        antlr3AsciiConsume                      (pANTLR3_INT_STREAM is);
40 static      ANTLR3_UCHAR    antlr3AsciiLA                               (pANTLR3_INT_STREAM is, ANTLR3_INT32 la);
41 static      ANTLR3_UCHAR    antlr3AsciiLA_ucase                 (pANTLR3_INT_STREAM is, ANTLR3_INT32 la);
42 static      ANTLR3_MARKER   antlr3AsciiIndex                    (pANTLR3_INT_STREAM is);
43 static      ANTLR3_MARKER   antlr3AsciiMark                             (pANTLR3_INT_STREAM is);
44 static      void                        antlr3AsciiRewind                       (pANTLR3_INT_STREAM is, ANTLR3_MARKER mark);
45 static      void                        antlr3AsciiRewindLast           (pANTLR3_INT_STREAM is);
46 static      void                        antlr3AsciiRelease                      (pANTLR3_INT_STREAM is, ANTLR3_MARKER mark);
47 static      void                        antlr3AsciiSeek                         (pANTLR3_INT_STREAM is, ANTLR3_MARKER seekPoint);
48 static          pANTLR3_STRING  antlr3AsciiGetSourceName        (pANTLR3_INT_STREAM is);
49
50 // ASCII Charstream API functions
51 //
52 static      void                        antlr3InputClose                        (pANTLR3_INPUT_STREAM input);
53 static      void                        antlr3InputReset                        (pANTLR3_INPUT_STREAM input);
54 static      void *                      antlr3AsciiLT                           (pANTLR3_INPUT_STREAM input, ANTLR3_INT32 lt);
55 static      ANTLR3_UINT32   antlr3AsciiSize                             (pANTLR3_INPUT_STREAM input);
56 static      pANTLR3_STRING  antlr3AsciiSubstr                   (pANTLR3_INPUT_STREAM input, ANTLR3_MARKER start, ANTLR3_MARKER stop);
57 static      ANTLR3_UINT32   antlr3AsciiGetLine                  (pANTLR3_INPUT_STREAM input);
58 static      void          *             antlr3AsciiGetLineBuf           (pANTLR3_INPUT_STREAM input);
59 static      ANTLR3_UINT32   antlr3AsciiGetCharPosition  (pANTLR3_INPUT_STREAM input);
60 static      void                        antlr3AsciiSetLine                      (pANTLR3_INPUT_STREAM input, ANTLR3_UINT32 line);
61 static      void                        antlr3AsciiSetCharPosition      (pANTLR3_INPUT_STREAM input, ANTLR3_UINT32 position);
62 static      void                        antlr3AsciiSetNewLineChar       (pANTLR3_INPUT_STREAM input, ANTLR3_UINT32 newlineChar);
63 static          void                    antlr3AsciiSetUcaseLA           (pANTLR3_INPUT_STREAM input, ANTLR3_BOOLEAN flag);
64
65 /// \brief Common function to setup function interface for an 8 bit ASCII input stream.
66 ///
67 /// \param input Input stream context pointer
68 ///
69 /// \remark
70 ///   - Many of the 8 bit ASCII oriented file stream handling functions will be usable
71 ///     by any or at least some other input streams. Therefore it is perfectly acceptable
72 ///     to call this function to install the ASCII handler then override just those functions
73 ///     that would not work for the particular input encoding, such as consume for instance.
74 /// 
75 void 
76 antlr3AsciiSetupStream  (pANTLR3_INPUT_STREAM input, ANTLR3_UINT32 type)
77 {
78     // Build a string factory for this stream
79      //
80     input->strFactory   = antlr3StringFactoryNew();
81
82     // Default stream set up is for ASCII, therefore there is nothing else
83     // to do but set it up as such
84     //
85     antlr3GenericSetupStream(input, type);
86 }
87
88
89 void
90 antlr3GenericSetupStream  (pANTLR3_INPUT_STREAM input, ANTLR3_UINT32 type)
91 {
92
93     /* Install function pointers for an 8 bit ASCII input
94      */
95
96     /* Allocate stream interface
97      */
98     input->istream                      =  antlr3IntStreamNew();
99     input->istream->type    = ANTLR3_CHARSTREAM;
100     input->istream->super   =  input;
101
102     input->istream->type        = type;
103
104     /* Intstream API
105      */
106     input->istream->consume                     =  antlr3AsciiConsume;                  /* Consume the next 8 bit character in the buffer                       */
107     input->istream->_LA                         =  antlr3AsciiLA;                               /* Return the UTF32 character at offset n (1 based)                     */
108     input->istream->index                       =  antlr3AsciiIndex;                    /* Current index (offset from first character                       */
109     input->istream->mark                        =  antlr3AsciiMark;                             /* Record the current lex state for later restore                       */
110     input->istream->rewind                      =  antlr3AsciiRewind;                   /* How to rewind the input                                                                      */
111     input->istream->rewindLast          =  antlr3AsciiRewindLast;               /* How to rewind the input                                                                      */
112     input->istream->seek                        =  antlr3AsciiSeek;                             /* How to seek to a specific point in the stream                    */
113     input->istream->release                     =  antlr3AsciiRelease;                  /* Reset marks after mark n                                                                     */
114         input->istream->getSourceName   =  antlr3AsciiGetSourceName;    // Return a string that names the input source
115
116         /* Charstream API
117      */
118     input->close                                        =  antlr3InputClose;                    /* Close down the stream completely                                                                             */
119     input->free                                         =  antlr3InputClose;                    /* Synonym for free                                                                                                             */
120     input->reset                                        =  antlr3InputReset;                    /* Reset input to start                                                                                                 */
121     input->_LT                                          =  antlr3AsciiLT;                               /* Same as _LA for 8 bit Ascii file                                                                             */
122     input->size                                         =  antlr3AsciiSize;                             /* Return the size of the input buffer                                                                  */
123     input->substr                                       =  antlr3AsciiSubstr;                   /* Return a string from the input stream                                                                */
124     input->getLine                                      =  antlr3AsciiGetLine;                  /* Return the current line number in the input stream                                   */
125     input->getLineBuf                           =  antlr3AsciiGetLineBuf;           /* Return a pointer to the start of the current line being consumed     */
126     input->getCharPositionInLine    =  antlr3AsciiGetCharPosition;  /* Return the offset into the current line of input                                         */
127     input->setLine                                      =  antlr3AsciiSetLine;                  /* Set the input stream line number (does not set buffer pointers)          */
128     input->setCharPositionInLine    =  antlr3AsciiSetCharPosition;  /* Set the offset in to the current line (does not set any pointers )   */
129     input->SetNewLineChar                       =  antlr3AsciiSetNewLineChar;   /* Set the value of the newline trigger character                                               */
130         input->setUcaseLA                               = antlr3AsciiSetUcaseLA;
131
132         input->charByteSize                             = 1;            // Size in bytes of characters in this stream.
133
134     /* Initialize entries for tables etc
135      */
136     input->markers  = NULL;
137
138     /* Set up the input stream brand new
139      */
140     input->reset(input);
141     
142     /* Install default line separator character (it can be replaced
143      * by the grammar programmer later)
144      */
145     input->SetNewLineChar(input, (ANTLR3_UCHAR)'\n');
146 }
147
148 static pANTLR3_STRING
149 antlr3AsciiGetSourceName(pANTLR3_INT_STREAM is)
150 {
151         return  is->streamName;
152 }
153
154 /** \brief Close down an input stream and free any memory allocated by it.
155  *
156  * \param input Input stream context pointer
157  */
158 static void
159 antlr3InputClose(pANTLR3_INPUT_STREAM input)
160 {
161     // Close any markers in the input stream
162     //
163     if  (input->markers != NULL)
164     {
165                 input->markers->free(input->markers);
166                 input->markers = NULL;
167     }
168
169     // Close the string factory
170     //
171     if  (input->strFactory != NULL)
172     {
173                 input->strFactory->close(input->strFactory);
174     }
175
176     // Free the input stream buffer if we allocated it
177     //
178     if  (input->isAllocated && input->data != NULL)
179     {
180                 ANTLR3_FREE(input->data);
181                 input->data = NULL;
182     }
183     
184     input->istream->free(input->istream);
185
186     // Finally, free the space for the structure itself
187     //
188     ANTLR3_FREE(input);
189
190     // Done
191     //
192 }
193
194 static void             
195 antlr3AsciiSetUcaseLA           (pANTLR3_INPUT_STREAM input, ANTLR3_BOOLEAN flag)
196 {
197         if      (flag)
198         {
199                 // Return the upper case version of the characters
200                 //
201                 input->istream->_LA                 =  antlr3AsciiLA_ucase;
202         }
203         else
204         {
205                 // Return the raw characters as they are in the buffer
206                 //
207                 input->istream->_LA                 =  antlr3AsciiLA;
208         }
209 }
210
211
212 /** \brief Reset a re-startable input stream to the start
213  *
214  * \param input Input stream context pointer
215  */
216 static void
217 antlr3InputReset(pANTLR3_INPUT_STREAM input)
218 {
219
220     input->nextChar             = input->data;  /* Input at first character */
221     input->line                 = 1;            /* starts at line 1         */
222     input->charPositionInLine   = -1;
223     input->currentLine          = input->data;
224     input->markDepth            = 0;            /* Reset markers            */
225     
226     /* Free up the markers table if it is there
227      */
228     if  (input->markers != NULL)
229     {
230         input->markers->free(input->markers);
231     }
232
233     /* Install a new markers table
234      */
235     input->markers  = antlr3VectorNew(0);
236 }
237
238 /** \brief Consume the next character in an 8 bit ASCII input stream
239  *
240  * \param input Input stream context pointer
241  */
242 static void
243 antlr3AsciiConsume(pANTLR3_INT_STREAM is)
244 {
245     pANTLR3_INPUT_STREAM input;
246
247     input   = ((pANTLR3_INPUT_STREAM) (is->super));
248
249     if  ((pANTLR3_UINT8)(input->nextChar) < (((pANTLR3_UINT8)input->data) + input->sizeBuf))
250     {   
251         /* Indicate one more character in this line
252          */
253         input->charPositionInLine++;
254         
255         if  ((ANTLR3_UCHAR)(*((pANTLR3_UINT8)input->nextChar)) == input->newlineChar)
256         {
257             /* Reset for start of a new line of input
258              */
259             input->line++;
260             input->charPositionInLine   = 0;
261             input->currentLine          = (void *)(((pANTLR3_UINT8)input->nextChar) + 1);
262         }
263
264         /* Increment to next character position
265          */
266         input->nextChar = (void *)(((pANTLR3_UINT8)input->nextChar) + 1);
267     }
268 }
269
270 /** \brief Return the input element assuming an 8 bit ascii input
271  *
272  * \param[in] input Input stream context pointer
273  * \param[in] la 1 based offset of next input stream element
274  *
275  * \return Next input character in internal ANTLR3 encoding (UTF32)
276  */
277 static ANTLR3_UCHAR 
278 antlr3AsciiLA(pANTLR3_INT_STREAM is, ANTLR3_INT32 la)
279 {
280     pANTLR3_INPUT_STREAM input;
281         
282     input   = ((pANTLR3_INPUT_STREAM) (is->super));
283
284     if  (( ((pANTLR3_UINT8)input->nextChar) + la - 1) >= (((pANTLR3_UINT8)input->data) + input->sizeBuf))
285     {
286                 return  ANTLR3_CHARSTREAM_EOF;
287     }
288     else
289     {
290                 return  (ANTLR3_UCHAR)(*((pANTLR3_UINT8)input->nextChar + la - 1));
291     }
292 }
293
294 /** \brief Return the input element assuming an 8 bit ASCII input and
295  *         always return the UPPER CASE character.
296  *                 Note that this is 8 bit and so we assume that the toupper
297  *                 function will use the correct locale for 8 bits.
298  *
299  * \param[in] input Input stream context pointer
300  * \param[in] la 1 based offset of next input stream element
301  *
302  * \return Next input character in internal ANTLR3 encoding (UTF32)
303  */
304 static ANTLR3_UCHAR
305 antlr3AsciiLA_ucase     (pANTLR3_INT_STREAM is, ANTLR3_INT32 la)
306 {
307     pANTLR3_INPUT_STREAM input;
308         
309     input   = ((pANTLR3_INPUT_STREAM) (is->super));
310
311     if  (( ((pANTLR3_UINT8)input->nextChar) + la - 1) >= (((pANTLR3_UINT8)input->data) + input->sizeBuf))
312     {
313                 return  ANTLR3_CHARSTREAM_EOF;
314     }
315     else
316     {
317                 return  (ANTLR3_UCHAR)toupper((*((pANTLR3_UINT8)input->nextChar + la - 1)));
318     }
319 }
320
321
322 /** \brief Return the input element assuming an 8 bit ascii input
323  *
324  * \param[in] input Input stream context pointer
325  * \param[in] lt 1 based offset of next input stream element
326  *
327  * \return Next input character in internal ANTLR3 encoding (UTF32)
328  */
329 static void * 
330 antlr3AsciiLT(pANTLR3_INPUT_STREAM input, ANTLR3_INT32 lt)
331 {
332     /* Casting is horrible but it means no warnings and LT should never be called
333      * on a character stream anyway I think. If it is then, the void * will need to be 
334      * cast back in a similar manner. Yuck! But this means that LT for Token streams and
335      * tree streams is correct.
336      */
337     return (ANTLR3_FUNC_PTR(input->istream->_LA(input->istream, lt)));
338 }
339
340 /** \brief Calculate the current index in the output stream.
341  * \param[in] input Input stream context pointer
342  */
343 static ANTLR3_MARKER
344 antlr3AsciiIndex(pANTLR3_INT_STREAM is)
345 {
346     pANTLR3_INPUT_STREAM input;
347
348     input   = ((pANTLR3_INPUT_STREAM) (is->super));
349
350     return  (ANTLR3_MARKER)(((pANTLR3_UINT8)input->nextChar));
351 }
352
353 /** \brief Return the size of the current input stream, as an Ascii file
354  *   which in this case is the total input. Other implementations may provide
355  *   more sophisticated implementations to deal with non-recoverable streams 
356  *   and so on.
357  *
358  * \param[in] input Input stream context pointer
359  */
360 static  ANTLR3_UINT32 
361 antlr3AsciiSize(pANTLR3_INPUT_STREAM input)
362 {
363     return  input->sizeBuf;
364 }
365
366 /** \brief Mark the current input point in an Ascii 8 bit stream
367  *  such as a file stream, where all the input is available in the
368  *  buffer.
369  *
370  * \param[in] is Input stream context pointer
371  */
372 static ANTLR3_MARKER
373 antlr3AsciiMark (pANTLR3_INT_STREAM is)
374 {
375     pANTLR3_LEX_STATE       state;
376     pANTLR3_INPUT_STREAM    input;
377
378     input   = ((pANTLR3_INPUT_STREAM) (is->super));
379
380     /* New mark point 
381      */
382     input->markDepth++;
383
384     /* See if we are revisiting a mark as we can just reuse the vector
385      * entry if we are, otherwise, we need a new one
386      */
387     if  (input->markDepth > input->markers->count)
388     {   
389         state   = ANTLR3_MALLOC(sizeof(ANTLR3_LEX_STATE));
390
391         /* Add it to the table
392          */
393         input->markers->add(input->markers, state, ANTLR3_FREE_FUNC);   /* No special structure, just free() on delete */
394     }
395     else
396     {
397         state   = (pANTLR3_LEX_STATE)input->markers->get(input->markers, input->markDepth - 1);
398
399         /* Assume no errors for speed, it will just blow up if the table failed
400          * for some reasons, hence lots of unit tests on the tables ;-)
401          */
402     }
403
404     /* We have created or retrieved the state, so update it with the current
405      * elements of the lexer state.
406      */
407     state->charPositionInLine   = input->charPositionInLine;
408     state->currentLine          = input->currentLine;
409     state->line                 = input->line;
410     state->nextChar             = input->nextChar;
411
412     is->lastMarker  = input->markDepth;
413
414     /* And that's it
415      */
416     return  input->markDepth;
417 }
418 /** \brief Rewind the lexer input to the state specified by the last produced mark.
419  * 
420  * \param[in] input Input stream context pointer
421  *
422  * \remark
423  * Assumes ASCII (or at least, 8 Bit) input stream.
424  */
425 static void
426 antlr3AsciiRewindLast   (pANTLR3_INT_STREAM is)
427 {
428     is->rewind(is, is->lastMarker);
429 }
430
431 /** \brief Rewind the lexer input to the state specified by the supplied mark.
432  * 
433  * \param[in] input Input stream context pointer
434  *
435  * \remark
436  * Assumes ASCII (or at least, 8 Bit) input stream.
437  */
438 static void
439 antlr3AsciiRewind       (pANTLR3_INT_STREAM is, ANTLR3_MARKER mark)
440 {
441     pANTLR3_LEX_STATE   state;
442     pANTLR3_INPUT_STREAM input;
443
444     input   = ((pANTLR3_INPUT_STREAM) is->super);
445
446     /* Perform any clean up of the marks
447      */
448     input->istream->release(input->istream, mark);
449
450     /* Find the supplied mark state 
451      */
452     state   = (pANTLR3_LEX_STATE)input->markers->get(input->markers, (ANTLR3_UINT32)(mark - 1));
453
454     /* Seek input pointer to the requested point (note we supply the void *pointer
455      * to whatever is implementing the int stream to seek).
456      */
457     antlr3AsciiSeek(is, (ANTLR3_MARKER)(state->nextChar));
458
459     /* Reset to the reset of the information in the mark
460      */
461     input->charPositionInLine   = state->charPositionInLine;
462     input->currentLine          = state->currentLine;
463     input->line                 = state->line;
464     input->nextChar             = state->nextChar;
465
466     /* And we are done
467      */
468 }
469
470 /** \brief Rewind the lexer input to the state specified by the supplied mark.
471  * 
472  * \param[in] input Input stream context pointer
473  *
474  * \remark
475  * Assumes ASCII (or at least, 8 Bit) input stream.
476  */
477 static void
478 antlr3AsciiRelease      (pANTLR3_INT_STREAM is, ANTLR3_MARKER mark)
479 {
480     pANTLR3_INPUT_STREAM input;
481
482     input   = ((pANTLR3_INPUT_STREAM) (is->super));
483
484     /* We don't do much here in fact as we never free any higher marks in
485      * the hashtable as we just resuse any memory allocated for them.
486      */
487     input->markDepth    = (ANTLR3_UINT32)(mark - 1);
488 }
489
490 /** \brief Rewind the lexer input to the state specified by the supplied mark.
491  * 
492  * \param[in] input Input stream context pointer
493  *
494  * \remark
495  * Assumes ASCII (or at least, 8 Bit) input stream.
496  */
497 static void
498 antlr3AsciiSeek (pANTLR3_INT_STREAM is, ANTLR3_MARKER seekPoint)
499 {
500         ANTLR3_INT32   count;
501         pANTLR3_INPUT_STREAM input;
502
503         input   = ANTLR3_FUNC_PTR(((pANTLR3_INPUT_STREAM) is->super));
504
505         /* If the requested seek point is less than the current
506         * input point, then we assume that we are resetting from a mark
507         * and do not need to scan, but can just set to there.
508         */
509         if      (seekPoint <= (ANTLR3_MARKER)(input->nextChar))
510         {
511                 input->nextChar = ((pANTLR3_UINT8) seekPoint);
512         }
513         else
514         {
515                 count   = (ANTLR3_UINT32)(seekPoint - (ANTLR3_MARKER)(input->nextChar));
516
517                 while (count--)
518                 {
519                         is->consume(is);
520                 }
521         }
522 }
523 /** Return a substring of the ASCII (8 bit) input stream in
524  *  newly allocated memory.
525  *
526  * \param input Input stream context pointer
527  * \param start Offset in input stream where the string starts
528  * \param stop  Offset in the input stream where the string ends.
529  */
530 static pANTLR3_STRING
531 antlr3AsciiSubstr               (pANTLR3_INPUT_STREAM input, ANTLR3_MARKER start, ANTLR3_MARKER stop)
532 {
533         return  input->strFactory->newPtr(input->strFactory, (pANTLR3_UINT8)start, (ANTLR3_UINT32)(stop - start + 1));
534 }
535
536 /** \brief Return the line number as understood by the 8 bit/ASCII input stream.
537  *
538  * \param input Input stream context pointer
539  * \return      Line number in input stream that we believe we are working on.
540  */
541 static ANTLR3_UINT32   
542 antlr3AsciiGetLine              (pANTLR3_INPUT_STREAM input)
543 {
544     return  input->line;
545 }
546
547 /** Return a pointer into the input stream that points at the start
548  *  of the current input line as triggered by the end of line character installed
549  *  for the stream ('\n' unless told differently).
550  *
551  * \param[in] input 
552  */
553 static void       * 
554 antlr3AsciiGetLineBuf   (pANTLR3_INPUT_STREAM input)
555 {
556     return  input->currentLine;
557 }
558
559 /** Return the current offset in to the current line in the input stream.
560  *
561  * \param input Input stream context pointer
562  * \return      Current line offset
563  */
564 static ANTLR3_UINT32
565 antlr3AsciiGetCharPosition      (pANTLR3_INPUT_STREAM input)
566 {
567     return  input->charPositionInLine;
568 }
569
570 /** Set the current line number as understood by the input stream.
571  *
572  * \param input Input stream context pointer
573  * \param line  Line number to tell the input stream we are on
574  *
575  * \remark
576  *  This function does not change any pointers, it just allows the programmer to set the
577  *  line number according to some external criterion, such as finding a lexed directive
578  *  like: #nnn "file.c" for instance, such that error reporting and so on in is in sync
579  *  with some original source format.
580  */
581 static void
582 antlr3AsciiSetLine              (pANTLR3_INPUT_STREAM input, ANTLR3_UINT32 line)
583 {
584     input->line = line;
585 }
586
587 /** Set the current offset in the current line to be a particular setting.
588  *
589  * \param[in] input    Input stream context pointer
590  * \param[in] position New setting for current offset.
591  *
592  * \remark
593  * This does not set the actual pointers in the input stream, it is purely for reporting
594  * purposes and so on as per antlr3AsciiSetLine();
595  */
596 static void
597 antlr3AsciiSetCharPosition      (pANTLR3_INPUT_STREAM input, ANTLR3_UINT32 position)
598 {
599     input->charPositionInLine = position;
600 }
601
602 /** Set the newline trigger character in the input stream to the supplied parameter.
603  *
604  * \param[in] input         Input stream context pointer
605  * \param[in] newlineChar   Character to set to be the newline trigger.
606  *
607  * \remark
608  *  - The supplied newLineChar is in UTF32 encoding (which means ASCII and latin1 etc
609  *    are the same encodings), but the input stream catered to by this function is 8 bit
610  *    only, so it is up to the programmer to ensure that the character supplied is valid.
611  */
612 static void 
613 antlr3AsciiSetNewLineChar       (pANTLR3_INPUT_STREAM input, ANTLR3_UINT32 newlineChar)
614 {
615     input->newlineChar  = newlineChar;
616 }
617
618
619