/* scanner.h - interface to re2c source-file support via scanner type * Copyright (c) 2002, 2003, Ed L. Cashin * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of the * License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA * */ #ifndef ELC_SCANNER_H #define ELC_SCANNER_H /* information for re2c-generated lexer */ typedef struct scanner_struct { int fd; unsigned char *buf_begin; /* pointer to allocated buffer */ unsigned char *token; /* the current token */ unsigned char *ptr; /* for use as re2c's "marker" */ unsigned char *cursor; /* points to re2c's current place; * will be one past any found token. */ unsigned char *pos; /* the beginning of the current line */ unsigned char *limit; /* the character past the input that's been read * into the buffer */ unsigned char *buf_end; /* points to the position in memory one past * the last character in the buffer */ unsigned char *eof; /* when there's no more data to read, this * will be equal to the cursor member. */ int line; /* the number of the current line in the * input. (first line is line one). */ } scanner; /* clean slate */ void scanner_init(scanner *s); /* scanner_init_for_buf - initialize a scanner for use in re2c code * that will scan the character buffer at buf. */ void scanner_init_for_buf(scanner *s, char *buf, int len); void scanner_destroy(scanner *s); /* release internal resources and leave * scanner in undefined state. */ /* scanner_fill - read from s->fd into the scanner's buffer */ unsigned char *scanner_fill(scanner *s, unsigned char *cursor); #endif