aboutsummaryrefslogtreecommitdiff
path: root/lib/forlanlex.l
diff options
context:
space:
mode:
Diffstat (limited to 'lib/forlanlex.l')
-rw-r--r--lib/forlanlex.l34
1 files changed, 24 insertions, 10 deletions
diff --git a/lib/forlanlex.l b/lib/forlanlex.l
index e3f9f26..c3797dd 100644
--- a/lib/forlanlex.l
+++ b/lib/forlanlex.l
@@ -16,6 +16,7 @@
along with Eclat. If not, see <http://www.gnu.org/licenses/>. */
#include "libeclat.h"
+#include <sysexits.h>
#include <grecs.h>
#include <grecs-locus.h>
#include "forlangrm.h"
@@ -28,14 +29,17 @@ static size_t forlan_input_pos;
#undef YY_INPUT
#define YY_INPUT(buf,result,max_size) \
do { \
- size_t __s = forlan_input_len - forlan_input_pos; \
- if (__s > max_size) \
- __s = max_size; \
- if (__s > 0) { \
- memcpy(buf, forlan_input_base, __s); \
- forlan_input_pos += __s; \
- } \
- result = __s; \
+ if (forlan_input_base) { \
+ size_t __s = forlan_input_len - forlan_input_pos; \
+ if (__s > max_size) \
+ __s = max_size; \
+ if (__s > 0) { \
+ memcpy(buf, forlan_input_base, __s); \
+ forlan_input_pos += __s; \
+ } \
+ result = __s; \
+ } else \
+ result = fread(buf, 1, max_size, yyin); \
} while(0)
#define YY_USER_ACTION do { \
@@ -120,8 +124,8 @@ yywrap()
}
void
-forlan_lex_begin(const char *input, size_t length,
- struct grecs_locus_point *pt)
+forlan_lex_from_buffer(const char *input, size_t length,
+ struct grecs_locus_point *pt)
{
forlan_input_base = input;
forlan_input_len = length;
@@ -131,6 +135,16 @@ forlan_lex_begin(const char *input, size_t length,
}
void
+forlan_lex_from_file(FILE *fp, struct grecs_locus_point *pt)
+{
+ yyin = fp;
+ forlan_input_base = NULL;
+ grecs_current_locus_point = *pt;
+ yy_flex_debug = debug_level(forlan_dbg) >= FORLAN_DBG_LEX;
+ grecs_line_acc_create();
+}
+
+void
forlan_lex_end()
{
grecs_line_acc_free();

Return to:

Send suggestions and report system problems to the System administrator.