summaryrefslogtreecommitdiffabout
path: root/lib/forlanlex.l
authorSergey Poznyakoff <gray@gnu.org.ua>2012-09-25 14:31:24 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2012-09-25 14:45:23 (GMT)
commit455e12faaf5efd997ff74ad04c0fcc62608477a5 (patch) (side-by-side diff)
tree46d24aba487fb2ea76078ef4da60357ff0a340e4 /lib/forlanlex.l
parent2f5d961c798802f1e467de1cd310f661e0a45fa7 (diff)
downloadeclat-455e12faaf5efd997ff74ad04c0fcc62608477a5.tar.gz
eclat-455e12faaf5efd997ff74ad04c0fcc62608477a5.tar.bz2
Use forlan to format the output.
* lib/forlan.h (forlan_lex_begin): Remove (forlan_lex_from_buffer) (forlan_lex_from_file): New protos. (forlan_parse): Remove. (forlan_parse_bufferm,forlan_parse_file): New protos. * lib/forlangrm.y (forlan_parse): Remove. (forlan_parse_bufferm,forlan_parse_file): New functions. * lib/forlanlex.l (YY_INPUT): Optionally, read input from file. (forlan_lex_begin): Remove (forlan_lex_from_buffer) (forlan_lex_from_file): New functions. * src/cmdline.opt: New options: --format, --sort * src/config.c: New statement: format. * src/eclat.c: Use output format scripts, if provided. * src/eclat.conf: Define output format for DescribeTags. * src/eclat.h: Include forlan.h (define_format): New proto. * tests/tforlan.c: New option: -s
Diffstat (limited to 'lib/forlanlex.l') (more/less context) (ignore whitespace changes)
-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.