This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: EOF character in parser


Geert Bosch wrote:

The Ada front end always terminates files with an EOF character
after they have been read in. One of the advantages is that you
never need checking for end of file, you'll encounter it during
parsing. Note that, with a little care, this even works if
an EOF character may appear in other situations.

For example, when skipping white space, you can just increase
the scan pointer until it doesn't point to white space. No checks
for an out-of-range pointer are necessary.

Indeed, this technique is colloquially referred to as "Place a known elephant in Cairo".


--
Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290
Saturnushof 14, 3738 XG  Maartensdijk, The Netherlands
Maintainer, GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
GNU Fortran 95: http://gcc.gnu.org/fortran/ (under construction)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]